Toniolo and Linder, Equation (3b), real

Percentage Accurate: 93.9% → 99.7%
Time: 14.2s
Alternatives: 23
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 23 alternatives:

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

Initial Program: 93.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.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 95.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.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. Add Preprocessing

Alternative 2: 76.9% accurate, 1.1× speedup?

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

\mathbf{elif}\;\sin kx \leq 0.002:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, kx \cdot \left(1 + kx \cdot \left(kx \cdot -0.16666666666666666\right)\right)\right)}{\sin th}}\\

\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (sin.f64 kx) < -0.0050000000000000001

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

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

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

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

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

        \[\leadsto \frac{\sin ky \cdot \sin th}{\mathsf{hypot}\left(\sin kx, {\sin ky}^{\color{blue}{1}}\right)} \]
      4. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

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

    if -0.0050000000000000001 < (sin.f64 kx) < 2e-3

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

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

      \[\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 \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), \color{blue}{\left(kx \cdot \left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)\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{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{*.f64}\left(kx, \color{blue}{\left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)}\right)\right)\right)\right) \]
      2. +-lowering-+.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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{6} \cdot {kx}^{2}\right)}\right)\right)\right)\right)\right) \]
      3. *-lowering-*.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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \color{blue}{\left({kx}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
      4. unpow2N/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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \left(kx \cdot \color{blue}{kx}\right)\right)\right)\right)\right)\right)\right) \]
      5. *-lowering-*.f6499.7%

        \[\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{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, \color{blue}{kx}\right)\right)\right)\right)\right)\right)\right) \]
    7. Simplified99.7%

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

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

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

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

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

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

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

    if 2e-3 < (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.f6463.1%

        \[\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. Simplified63.1%

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

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

Alternative 3: 76.6% accurate, 1.1× speedup?

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

\mathbf{elif}\;\sin kx \leq 0.002:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, kx \cdot \left(1 + kx \cdot \left(kx \cdot -0.16666666666666666\right)\right)\right)}{\sin th}}\\

\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (sin.f64 kx) < -0.0050000000000000001

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

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

      \[\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. Simplified53.5%

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

      if -0.0050000000000000001 < (sin.f64 kx) < 2e-3

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

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

        \[\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 \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), \color{blue}{\left(kx \cdot \left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)\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{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{*.f64}\left(kx, \color{blue}{\left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)}\right)\right)\right)\right) \]
        2. +-lowering-+.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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{6} \cdot {kx}^{2}\right)}\right)\right)\right)\right)\right) \]
        3. *-lowering-*.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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \color{blue}{\left({kx}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
        4. unpow2N/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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \left(kx \cdot \color{blue}{kx}\right)\right)\right)\right)\right)\right)\right) \]
        5. *-lowering-*.f6499.7%

          \[\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{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, \color{blue}{kx}\right)\right)\right)\right)\right)\right)\right) \]
      7. Simplified99.7%

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

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

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

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

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

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

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

      if 2e-3 < (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.f6463.1%

          \[\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. Simplified63.1%

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

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

    Alternative 4: 76.7% accurate, 1.1× speedup?

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

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

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

        \[\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. Simplified53.5%

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

        if -0.0050000000000000001 < (sin.f64 kx) < 2e-3

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

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

          \[\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 \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), \color{blue}{\left(kx \cdot \left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)\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{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{*.f64}\left(kx, \color{blue}{\left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)}\right)\right)\right)\right) \]
          2. +-lowering-+.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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{6} \cdot {kx}^{2}\right)}\right)\right)\right)\right)\right) \]
          3. *-lowering-*.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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \color{blue}{\left({kx}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
          4. unpow2N/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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \left(kx \cdot \color{blue}{kx}\right)\right)\right)\right)\right)\right)\right) \]
          5. *-lowering-*.f6499.7%

            \[\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{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, \color{blue}{kx}\right)\right)\right)\right)\right)\right)\right) \]
        7. Simplified99.7%

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

        if 2e-3 < (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.f6463.1%

            \[\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. Simplified63.1%

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

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

      Alternative 5: 76.6% accurate, 1.2× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin kx \leq -0.005:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot th\\ \mathbf{elif}\;\sin kx \leq 0.002:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(kx, \sin ky\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \end{array} \end{array} \]
      (FPCore (kx ky th)
       :precision binary64
       (if (<= (sin kx) -0.005)
         (* (/ (sin ky) (hypot (sin kx) (sin ky))) th)
         (if (<= (sin kx) 0.002)
           (* (sin th) (/ (sin ky) (hypot kx (sin ky))))
           (* (sin th) (/ (sin ky) (sin kx))))))
      double code(double kx, double ky, double th) {
      	double tmp;
      	if (sin(kx) <= -0.005) {
      		tmp = (sin(ky) / hypot(sin(kx), sin(ky))) * th;
      	} else if (sin(kx) <= 0.002) {
      		tmp = sin(th) * (sin(ky) / hypot(kx, sin(ky)));
      	} else {
      		tmp = sin(th) * (sin(ky) / sin(kx));
      	}
      	return tmp;
      }
      
      public static double code(double kx, double ky, double th) {
      	double tmp;
      	if (Math.sin(kx) <= -0.005) {
      		tmp = (Math.sin(ky) / Math.hypot(Math.sin(kx), Math.sin(ky))) * th;
      	} else if (Math.sin(kx) <= 0.002) {
      		tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(kx, Math.sin(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) <= -0.005:
      		tmp = (math.sin(ky) / math.hypot(math.sin(kx), math.sin(ky))) * th
      	elif math.sin(kx) <= 0.002:
      		tmp = math.sin(th) * (math.sin(ky) / math.hypot(kx, math.sin(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) <= -0.005)
      		tmp = Float64(Float64(sin(ky) / hypot(sin(kx), sin(ky))) * th);
      	elseif (sin(kx) <= 0.002)
      		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(kx, sin(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) <= -0.005)
      		tmp = (sin(ky) / hypot(sin(kx), sin(ky))) * th;
      	elseif (sin(kx) <= 0.002)
      		tmp = sin(th) * (sin(ky) / hypot(kx, sin(ky)));
      	else
      		tmp = sin(th) * (sin(ky) / sin(kx));
      	end
      	tmp_2 = tmp;
      end
      
      code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 0.002], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[kx ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $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 -0.005:\\
      \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot th\\
      
      \mathbf{elif}\;\sin kx \leq 0.002:\\
      \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(kx, \sin ky\right)}\\
      
      \mathbf{else}:\\
      \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if (sin.f64 kx) < -0.0050000000000000001

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

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

          \[\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. Simplified53.5%

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

          if -0.0050000000000000001 < (sin.f64 kx) < 2e-3

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

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

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

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

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

            if 2e-3 < (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.f6463.1%

                \[\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. Simplified63.1%

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

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

          Alternative 6: 76.7% accurate, 1.2× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin kx \leq -0.005:\\ \;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{elif}\;\sin kx \leq 0.002:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(kx, \sin ky\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \end{array} \end{array} \]
          (FPCore (kx ky th)
           :precision binary64
           (if (<= (sin kx) -0.005)
             (* (sin ky) (/ th (hypot (sin ky) (sin kx))))
             (if (<= (sin kx) 0.002)
               (* (sin th) (/ (sin ky) (hypot kx (sin ky))))
               (* (sin th) (/ (sin ky) (sin kx))))))
          double code(double kx, double ky, double th) {
          	double tmp;
          	if (sin(kx) <= -0.005) {
          		tmp = sin(ky) * (th / hypot(sin(ky), sin(kx)));
          	} else if (sin(kx) <= 0.002) {
          		tmp = sin(th) * (sin(ky) / hypot(kx, sin(ky)));
          	} else {
          		tmp = sin(th) * (sin(ky) / sin(kx));
          	}
          	return tmp;
          }
          
          public static double code(double kx, double ky, double th) {
          	double tmp;
          	if (Math.sin(kx) <= -0.005) {
          		tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(ky), Math.sin(kx)));
          	} else if (Math.sin(kx) <= 0.002) {
          		tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(kx, Math.sin(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) <= -0.005:
          		tmp = math.sin(ky) * (th / math.hypot(math.sin(ky), math.sin(kx)))
          	elif math.sin(kx) <= 0.002:
          		tmp = math.sin(th) * (math.sin(ky) / math.hypot(kx, math.sin(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) <= -0.005)
          		tmp = Float64(sin(ky) * Float64(th / hypot(sin(ky), sin(kx))));
          	elseif (sin(kx) <= 0.002)
          		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(kx, sin(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) <= -0.005)
          		tmp = sin(ky) * (th / hypot(sin(ky), sin(kx)));
          	elseif (sin(kx) <= 0.002)
          		tmp = sin(th) * (sin(ky) / hypot(kx, sin(ky)));
          	else
          		tmp = sin(th) * (sin(ky) / sin(kx));
          	end
          	tmp_2 = tmp;
          end
          
          code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 0.002], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[kx ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $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 -0.005:\\
          \;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
          
          \mathbf{elif}\;\sin kx \leq 0.002:\\
          \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(kx, \sin ky\right)}\\
          
          \mathbf{else}:\\
          \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if (sin.f64 kx) < -0.0050000000000000001

            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.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 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. Simplified53.5%

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

              if -0.0050000000000000001 < (sin.f64 kx) < 2e-3

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

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

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

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

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

                if 2e-3 < (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.f6463.1%

                    \[\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. Simplified63.1%

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

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

              Alternative 7: 76.6% accurate, 1.2× speedup?

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

                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.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 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. Simplified53.5%

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

                  if -0.0050000000000000001 < (sin.f64 kx) < 2e-3

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

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

                    \[\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 \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), \color{blue}{kx}\right)\right)\right) \]
                  6. Step-by-step derivation
                    1. Simplified99.4%

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

                    if 2e-3 < (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.f6463.1%

                        \[\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. Simplified63.1%

                      \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
                  7. Recombined 3 regimes into one program.
                  8. Final simplification78.6%

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

                  Alternative 8: 75.5% accurate, 1.2× speedup?

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

                    1. Initial program 99.8%

                      \[\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. Simplified48.8%

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

                      if -0.10000000000000001 < (sin.f64 ky) < 0.050000000000000003

                      1. Initial program 91.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.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), \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. Simplified96.0%

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

                        if 0.050000000000000003 < (sin.f64 ky)

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

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

                          \[\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.f6463.5%

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

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

                      Alternative 9: 45.0% accurate, 1.4× speedup?

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

                        1. Initial program 99.8%

                          \[\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 \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), \color{blue}{\left(kx \cdot \left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)\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{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{*.f64}\left(kx, \color{blue}{\left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)}\right)\right)\right)\right) \]
                          2. +-lowering-+.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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{6} \cdot {kx}^{2}\right)}\right)\right)\right)\right)\right) \]
                          3. *-lowering-*.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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \color{blue}{\left({kx}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
                          4. unpow2N/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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \left(kx \cdot \color{blue}{kx}\right)\right)\right)\right)\right)\right)\right) \]
                          5. *-lowering-*.f6460.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{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, \color{blue}{kx}\right)\right)\right)\right)\right)\right)\right) \]
                        7. Simplified60.6%

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

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

                          if -0.220000000000000001 < (sin.f64 ky) < 4.0000000000000001e-13

                          1. Initial program 91.6%

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

                            \[\leadsto \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.f6441.1%

                              \[\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. Simplified41.1%

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

                          if 4.0000000000000001e-13 < (sin.f64 ky)

                          1. Initial program 99.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.f6460.8%

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

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

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

                        Alternative 10: 41.9% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              if -0.050000000000000003 < (sin.f64 kx) < 4.00000000000000016e-108

                              1. Initial program 90.2%

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

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

                                \[\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.f6434.4%

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

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

                              if 4.00000000000000016e-108 < (sin.f64 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(\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.f6454.3%

                                  \[\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. Simplified54.3%

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

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

                            Alternative 11: 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 95.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. Add Preprocessing

                            Alternative 12: 39.7% accurate, 1.7× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin kx \leq 4 \cdot 10^{-108}:\\ \;\;\;\;\left(\sin ky \cdot \sin th\right) \cdot \frac{1}{\sin ky}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \end{array} \end{array} \]
                            (FPCore (kx ky th)
                             :precision binary64
                             (if (<= (sin kx) 4e-108)
                               (* (* (sin ky) (sin th)) (/ 1.0 (sin ky)))
                               (* (sin th) (/ (sin ky) (sin kx)))))
                            double code(double kx, double ky, double th) {
                            	double tmp;
                            	if (sin(kx) <= 4e-108) {
                            		tmp = (sin(ky) * sin(th)) * (1.0 / sin(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) <= 4d-108) then
                                    tmp = (sin(ky) * sin(th)) * (1.0d0 / sin(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) <= 4e-108) {
                            		tmp = (Math.sin(ky) * Math.sin(th)) * (1.0 / Math.sin(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) <= 4e-108:
                            		tmp = (math.sin(ky) * math.sin(th)) * (1.0 / math.sin(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) <= 4e-108)
                            		tmp = Float64(Float64(sin(ky) * sin(th)) * Float64(1.0 / sin(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) <= 4e-108)
                            		tmp = (sin(ky) * sin(th)) * (1.0 / sin(ky));
                            	else
                            		tmp = sin(th) * (sin(ky) / sin(kx));
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], 4e-108], N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sin[ky], $MachinePrecision]), $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 4 \cdot 10^{-108}:\\
                            \;\;\;\;\left(\sin ky \cdot \sin th\right) \cdot \frac{1}{\sin 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) < 4.00000000000000016e-108

                              1. Initial program 93.9%

                                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                              2. Add Preprocessing
                              3. Taylor expanded in kx around 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. Step-by-step derivation
                                1. associate-*l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(th\right)\right), \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(ky\right)\right)\right) \]
                              10. Simplified28.9%

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

                              if 4.00000000000000016e-108 < (sin.f64 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(\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.f6454.3%

                                  \[\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. Simplified54.3%

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

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

                            Alternative 13: 55.2% accurate, 1.7× speedup?

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

                              1. Initial program 95.3%

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

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

                                if 1.1200000000000001e29 < th < 2.10000000000000002e83

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

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

                                  \[\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.f6429.1%

                                    \[\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. Simplified29.1%

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

                                if 2.10000000000000002e83 < th

                                1. Initial program 96.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.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.f6426.2%

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

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

                              Alternative 14: 38.9% accurate, 2.2× speedup?

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

                                1. Initial program 94.3%

                                  \[\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.f6429.8%

                                    \[\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. Simplified29.8%

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

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

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

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

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

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

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

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

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

                                if 4.0000000000000001e-13 < (sin.f64 ky)

                                1. Initial program 99.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.f6460.8%

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

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

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

                              Alternative 15: 31.6% accurate, 2.3× speedup?

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

                                1. Initial program 93.8%

                                  \[\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.f6424.1%

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

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

                                if 7.4999999999999993e-108 < kx

                                1. Initial program 99.6%

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

                                  \[\leadsto \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.f6442.3%

                                    \[\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. Simplified42.3%

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

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

                              Alternative 16: 31.6% accurate, 2.3× speedup?

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

                                1. Initial program 93.8%

                                  \[\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.f6424.1%

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

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

                                if 5.4000000000000001e-108 < kx

                                1. Initial program 99.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 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.f6442.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. Simplified42.2%

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

                              Alternative 17: 31.9% accurate, 3.4× speedup?

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

                                1. Initial program 93.8%

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

                                  \[\leadsto \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.f6430.4%

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

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

                                if 2.3999999999999999e-13 < ky

                                1. Initial program 99.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.f6429.4%

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

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

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

                              Alternative 18: 31.9% accurate, 3.4× speedup?

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

                                1. Initial program 93.8%

                                  \[\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), \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.f6430.9%

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

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

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

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

                                  if 2.3999999999999999e-13 < ky

                                  1. Initial program 99.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.f6429.4%

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

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

                                Alternative 19: 26.3% accurate, 6.4× speedup?

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

                                  1. Initial program 94.5%

                                    \[\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.f6424.8%

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

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

                                  if 0.065000000000000002 < 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 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.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{sin.f64}\left(ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                  5. Simplified99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \left(\sin ky \cdot \color{blue}{th}\right) \cdot \frac{1}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \]
                                    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.f6428.7%

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

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

                                  Alternative 20: 22.7% accurate, 6.7× speedup?

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

                                    1. Initial program 94.5%

                                      \[\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 \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), \color{blue}{\left(kx \cdot \left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)\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{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{*.f64}\left(kx, \color{blue}{\left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)}\right)\right)\right)\right) \]
                                      2. +-lowering-+.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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{6} \cdot {kx}^{2}\right)}\right)\right)\right)\right)\right) \]
                                      3. *-lowering-*.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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \color{blue}{\left({kx}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
                                      4. unpow2N/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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \left(kx \cdot \color{blue}{kx}\right)\right)\right)\right)\right)\right)\right) \]
                                      5. *-lowering-*.f6462.3%

                                        \[\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{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, \color{blue}{kx}\right)\right)\right)\right)\right)\right)\right) \]
                                    7. Simplified62.3%

                                      \[\leadsto \sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx \cdot \left(1 + -0.16666666666666666 \cdot \left(kx \cdot kx\right)\right)}\right)} \]
                                    8. 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{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, kx\right)\right)\right)\right)\right)\right)\right) \]
                                    9. 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{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, kx\right)\right)\right)\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{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, kx\right)\right)\right)\right)\right)\right)\right) \]
                                      3. *-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(\frac{-1}{6}, \left({th}^{2}\right)\right)\right)\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, kx\right)\right)\right)\right)\right)\right)\right) \]
                                      4. unpow2N/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(\frac{-1}{6}, \left(th \cdot th\right)\right)\right)\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, kx\right)\right)\right)\right)\right)\right)\right) \]
                                      5. *-lowering-*.f6432.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    if 3.6000000000000001e-183 < ky

                                    1. Initial program 97.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.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.f6427.7%

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

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

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

                                  Alternative 21: 17.2% accurate, 27.3× speedup?

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

                                    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 \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), \color{blue}{\left(kx \cdot \left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)\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{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{*.f64}\left(kx, \color{blue}{\left(1 + \frac{-1}{6} \cdot {kx}^{2}\right)}\right)\right)\right)\right) \]
                                      2. +-lowering-+.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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{6} \cdot {kx}^{2}\right)}\right)\right)\right)\right)\right) \]
                                      3. *-lowering-*.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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \color{blue}{\left({kx}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
                                      4. unpow2N/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), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \left(kx \cdot \color{blue}{kx}\right)\right)\right)\right)\right)\right)\right) \]
                                      5. *-lowering-*.f6463.2%

                                        \[\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{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, \color{blue}{kx}\right)\right)\right)\right)\right)\right)\right) \]
                                    7. Simplified63.2%

                                      \[\leadsto \sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx \cdot \left(1 + -0.16666666666666666 \cdot \left(kx \cdot kx\right)\right)}\right)} \]
                                    8. 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{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, kx\right)\right)\right)\right)\right)\right)\right) \]
                                    9. 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{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, kx\right)\right)\right)\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{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, kx\right)\right)\right)\right)\right)\right)\right) \]
                                      3. *-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(\frac{-1}{6}, \left({th}^{2}\right)\right)\right)\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, kx\right)\right)\right)\right)\right)\right)\right) \]
                                      4. unpow2N/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(\frac{-1}{6}, \left(th \cdot th\right)\right)\right)\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{*.f64}\left(kx, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, kx\right)\right)\right)\right)\right)\right)\right) \]
                                      5. *-lowering-*.f6434.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(ky, kx\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(th, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(th, th\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \left(kx \cdot \color{blue}{kx}\right)\right)\right)\right)\right) \]
                                      13. *-lowering-*.f6414.3%

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(ky, kx\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(th, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(th, th\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(kx, \color{blue}{kx}\right)\right)\right)\right)\right) \]
                                    13. Simplified14.3%

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

                                    if 3.79999999999999985e-129 < ky

                                    1. Initial program 99.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.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.f6426.8%

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

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

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

                                        \[\leadsto \color{blue}{th} \]
                                    10. Recombined 2 regimes into one program.
                                    11. Final simplification14.8%

                                      \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 3.8 \cdot 10^{-129}:\\ \;\;\;\;\frac{ky}{kx} \cdot \frac{th \cdot \left(1 + \left(th \cdot th\right) \cdot -0.16666666666666666\right)}{1 + -0.16666666666666666 \cdot \left(kx \cdot kx\right)}\\ \mathbf{else}:\\ \;\;\;\;th\\ \end{array} \]
                                    12. Add Preprocessing

                                    Alternative 22: 16.5% accurate, 117.9× speedup?

                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 4.4 \cdot 10^{-131}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;th\\ \end{array} \end{array} \]
                                    (FPCore (kx ky th) :precision binary64 (if (<= ky 4.4e-131) 0.0 th))
                                    double code(double kx, double ky, double th) {
                                    	double tmp;
                                    	if (ky <= 4.4e-131) {
                                    		tmp = 0.0;
                                    	} else {
                                    		tmp = th;
                                    	}
                                    	return tmp;
                                    }
                                    
                                    real(8) function code(kx, ky, th)
                                        real(8), intent (in) :: kx
                                        real(8), intent (in) :: ky
                                        real(8), intent (in) :: th
                                        real(8) :: tmp
                                        if (ky <= 4.4d-131) then
                                            tmp = 0.0d0
                                        else
                                            tmp = th
                                        end if
                                        code = tmp
                                    end function
                                    
                                    public static double code(double kx, double ky, double th) {
                                    	double tmp;
                                    	if (ky <= 4.4e-131) {
                                    		tmp = 0.0;
                                    	} else {
                                    		tmp = th;
                                    	}
                                    	return tmp;
                                    }
                                    
                                    def code(kx, ky, th):
                                    	tmp = 0
                                    	if ky <= 4.4e-131:
                                    		tmp = 0.0
                                    	else:
                                    		tmp = th
                                    	return tmp
                                    
                                    function code(kx, ky, th)
                                    	tmp = 0.0
                                    	if (ky <= 4.4e-131)
                                    		tmp = 0.0;
                                    	else
                                    		tmp = th;
                                    	end
                                    	return tmp
                                    end
                                    
                                    function tmp_2 = code(kx, ky, th)
                                    	tmp = 0.0;
                                    	if (ky <= 4.4e-131)
                                    		tmp = 0.0;
                                    	else
                                    		tmp = th;
                                    	end
                                    	tmp_2 = tmp;
                                    end
                                    
                                    code[kx_, ky_, th_] := If[LessEqual[ky, 4.4e-131], 0.0, th]
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    \begin{array}{l}
                                    \mathbf{if}\;ky \leq 4.4 \cdot 10^{-131}:\\
                                    \;\;\;\;0\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;th\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. if ky < 4.3999999999999999e-131

                                      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), \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.f6430.4%

                                          \[\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. Simplified30.4%

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

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

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

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

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

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

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

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

                                          \[\leadsto \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), \left(\sin kx \cdot 2\right)\right) \]
                                        9. +-commutativeN/A

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

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

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

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

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

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

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

                                          \[\leadsto 0 \]
                                      12. Simplified15.4%

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

                                      if 4.3999999999999999e-131 < ky

                                      1. Initial program 99.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.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.f6426.8%

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

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

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

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

                                      Alternative 23: 12.0% 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 95.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 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.f6424.5%

                                          \[\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. Simplified24.5%

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

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

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

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

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

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

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

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

                                          \[\leadsto \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), \left(\sin kx \cdot 2\right)\right) \]
                                        9. +-commutativeN/A

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

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

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

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

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

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

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

                                          \[\leadsto 0 \]
                                      12. Simplified11.3%

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

                                      Reproduce

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