Toniolo and Linder, Equation (3b), real

Percentage Accurate: 94.5% → 99.7%
Time: 15.3s
Alternatives: 25
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 25 alternatives:

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

Initial Program: 94.5% 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 th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (/ (sin th) (/ (hypot (sin ky) (sin kx)) (sin ky))))
double code(double kx, double ky, double th) {
	return sin(th) / (hypot(sin(ky), sin(kx)) / sin(ky));
}
public static double code(double kx, double ky, double th) {
	return Math.sin(th) / (Math.hypot(Math.sin(ky), Math.sin(kx)) / Math.sin(ky));
}
def code(kx, ky, th):
	return math.sin(th) / (math.hypot(math.sin(ky), math.sin(kx)) / math.sin(ky))
function code(kx, ky, th)
	return Float64(sin(th) / Float64(hypot(sin(ky), sin(kx)) / sin(ky)))
end
function tmp = code(kx, ky, th)
	tmp = sin(th) / (hypot(sin(ky), sin(kx)) / sin(ky));
end
code[kx_, ky_, th_] := N[(N[Sin[th], $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[\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. accelerator-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) \]
    4. 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) \]
    5. sin-lowering-sin.f6499.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 71.9% accurate, 1.4× speedup?

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

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

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

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
      10. accelerator-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) \]
      11. 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) \]
      12. sin-lowering-sin.f6499.6%

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(th, \mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot {th}^{2}\right)\right)\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
      3. *-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{sin.f64}\left(kx\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{sin.f64}\left(kx\right)\right)\right)\right) \]
      5. *-lowering-*.f6459.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{sin.f64}\left(kx\right)\right)\right)\right) \]
    7. Simplified59.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, \sin kx\right)} \]
    8. Taylor expanded in kx around 0

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

        \[\leadsto \sin ky \cdot \frac{th \cdot \left(1 + -0.16666666666666666 \cdot \left(th \cdot th\right)\right)}{\mathsf{hypot}\left(\sin ky, \color{blue}{kx}\right)} \]
      2. 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), kx\right)\right)\right) \]
      3. Step-by-step derivation
        1. Simplified30.5%

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

        if -0.0100000000000000002 < (sin.f64 ky) < 1e-3

        1. Initial program 83.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. accelerator-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) \]
          11. 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) \]
          12. 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), \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. Simplified99.0%

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

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

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

            if 1e-3 < (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. accelerator-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) \]
              11. 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) \]
              12. 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 \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \color{blue}{\left(\frac{\sin th}{\sin ky}\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 ky}\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}{ky}\right)\right) \]
              3. sin-lowering-sin.f6449.2%

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

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

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

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

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

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin th\right), \sin ky\right) \]
              5. 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), \sin ky\right) \]
              6. sin-lowering-sin.f6449.2%

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

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

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

          Alternative 3: 99.7% accurate, 1.4× speedup?

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

            \[\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. accelerator-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) \]
            4. 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) \]
            5. sin-lowering-sin.f6499.6%

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

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

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

          Alternative 4: 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 90.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. accelerator-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) \]
            11. 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) \]
            12. 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 5: 66.4% accurate, 1.7× speedup?

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

            1. Initial program 92.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. accelerator-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) \]
              11. 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) \]
              12. sin-lowering-sin.f6499.6%

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

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(th, \mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot {th}^{2}\right)\right)\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
              3. *-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{sin.f64}\left(kx\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{sin.f64}\left(kx\right)\right)\right)\right) \]
              5. *-lowering-*.f6468.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{sin.f64}\left(kx\right)\right)\right)\right) \]
            7. Simplified68.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, \sin kx\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 + \sin kx \cdot \sin kx}}{th \cdot \left(1 + \frac{-1}{6} \cdot \left(th \cdot th\right)\right)}}} \]
              2. un-div-invN/A

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

                \[\leadsto \mathsf{/.f64}\left(\sin ky, \color{blue}{\left(\frac{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}{th \cdot \left(1 + \frac{-1}{6} \cdot \left(th \cdot th\right)\right)}\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 + \sin kx \cdot \sin kx}}}{th \cdot \left(1 + \frac{-1}{6} \cdot \left(th \cdot th\right)\right)}\right)\right) \]
              5. associate-/r*N/A

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

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

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

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

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

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

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

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

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

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

            if 0.0152 < th

            1. Initial program 85.7%

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
              10. accelerator-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) \]
              11. 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) \]
              12. sin-lowering-sin.f6499.6%

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

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

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

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

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

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

              Alternative 6: 66.4% accurate, 1.7× speedup?

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

                1. Initial program 92.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. accelerator-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) \]
                  11. 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) \]
                  12. sin-lowering-sin.f6499.6%

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

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

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

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

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

                if 0.0037000000000000002 < th

                1. Initial program 85.7%

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                  10. accelerator-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) \]
                  11. 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) \]
                  12. sin-lowering-sin.f6499.6%

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

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

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

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

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

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

                  Alternative 7: 66.3% accurate, 1.7× speedup?

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

                    1. Initial program 92.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. accelerator-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) \]
                      11. 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) \]
                      12. sin-lowering-sin.f6499.6%

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

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

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

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

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(th, \mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot {th}^{2}\right)\right)\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                      3. *-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{sin.f64}\left(kx\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{sin.f64}\left(kx\right)\right)\right)\right) \]
                      5. *-lowering-*.f6468.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{sin.f64}\left(kx\right)\right)\right)\right) \]
                    7. Simplified68.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, \sin kx\right)} \]
                    8. Step-by-step derivation
                      1. *-commutativeN/A

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

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

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

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

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

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

                    if 0.0122000000000000008 < th

                    1. Initial program 85.7%

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

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

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

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

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

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

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

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

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

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                      10. accelerator-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) \]
                      11. 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) \]
                      12. sin-lowering-sin.f6499.6%

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

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

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

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

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

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

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

                      Alternative 8: 66.4% accurate, 1.7× speedup?

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

                        1. Initial program 92.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. accelerator-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) \]
                          4. 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) \]
                          5. sin-lowering-sin.f6499.7%

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

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

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

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

                          if 3.4999999999999997e-5 < th

                          1. Initial program 85.7%

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

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

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                            10. accelerator-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) \]
                            11. 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) \]
                            12. sin-lowering-sin.f6499.6%

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

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

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

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

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

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

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

                            Alternative 9: 66.4% accurate, 1.7× speedup?

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

                              1. Initial program 92.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. accelerator-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) \]
                                11. 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) \]
                                12. 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. Simplified68.7%

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

                                if 0.00239999999999999979 < th

                                1. Initial program 85.7%

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

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

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

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

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

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

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

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

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

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                  10. accelerator-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) \]
                                  11. 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) \]
                                  12. sin-lowering-sin.f6499.6%

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

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

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

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

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

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

                                  Alternative 10: 71.0% accurate, 1.7× speedup?

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

                                    1. Initial program 88.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. accelerator-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) \]
                                      11. 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) \]
                                      12. sin-lowering-sin.f6499.6%

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

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

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

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

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

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

                                        if 1e-3 < (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. accelerator-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) \]
                                          11. 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) \]
                                          12. 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 \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \color{blue}{\left(\frac{\sin th}{\sin ky}\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 ky}\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}{ky}\right)\right) \]
                                          3. sin-lowering-sin.f6449.2%

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

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

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

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

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

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin th\right), \sin ky\right) \]
                                          5. 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), \sin ky\right) \]
                                          6. sin-lowering-sin.f6449.2%

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

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

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

                                      Alternative 11: 41.1% accurate, 1.7× speedup?

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

                                        1. Initial program 87.7%

                                          \[\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. accelerator-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) \]
                                          4. 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) \]
                                          5. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(kx\right), \mathsf{sin.f64}\left(\color{blue}{ky}\right)\right)\right) \]
                                        10. Simplified33.8%

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

                                        if 9.99999999999999943e-30 < (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. accelerator-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) \]
                                          11. 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) \]
                                          12. 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.f6448.4%

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

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

                                      Alternative 12: 41.1% accurate, 1.7× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq 10^{-29}:\\ \;\;\;\;\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) 1e-29) (* (sin th) (/ (sin ky) (sin kx))) (sin th)))
                                      double code(double kx, double ky, double th) {
                                      	double tmp;
                                      	if (sin(ky) <= 1e-29) {
                                      		tmp = sin(th) * (sin(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) <= 1d-29) then
                                              tmp = sin(th) * (sin(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) <= 1e-29) {
                                      		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) <= 1e-29:
                                      		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) <= 1e-29)
                                      		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) <= 1e-29)
                                      		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], 1e-29], 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 10^{-29}:\\
                                      \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;\sin th\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if (sin.f64 ky) < 9.99999999999999943e-30

                                        1. Initial program 87.7%

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

                                          \[\leadsto \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.f6433.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. Simplified33.8%

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

                                        if 9.99999999999999943e-30 < (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. accelerator-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) \]
                                          11. 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) \]
                                          12. 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.f6448.4%

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

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

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

                                      Alternative 13: 41.1% accurate, 1.7× speedup?

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

                                        1. Initial program 87.7%

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

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

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

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

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

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

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

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

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

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                          10. accelerator-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) \]
                                          11. 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) \]
                                          12. 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.f6433.8%

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

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

                                        if 9.99999999999999943e-30 < (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. accelerator-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) \]
                                          11. 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) \]
                                          12. 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.f6448.4%

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

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

                                      Alternative 14: 33.4% accurate, 3.2× speedup?

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

                                        1. Initial program 86.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. accelerator-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) \]
                                          11. 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) \]
                                          12. sin-lowering-sin.f6499.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          if 3.99999999999999974e-88 < (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. accelerator-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) \]
                                            11. 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) \]
                                            12. 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.f6445.3%

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

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

                                        Alternative 15: 32.7% accurate, 3.4× speedup?

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

                                          1. Initial program 88.0%

                                            \[\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. accelerator-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) \]
                                            4. 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) \]
                                            5. sin-lowering-sin.f6499.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          if 1.99999999999999989e-29 < ky

                                          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. accelerator-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) \]
                                            11. 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) \]
                                            12. 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.f6435.6%

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

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

                                        Alternative 16: 32.7% accurate, 3.4× speedup?

                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 9.8 \cdot 10^{-30}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                        (FPCore (kx ky th)
                                         :precision binary64
                                         (if (<= ky 9.8e-30) (* (sin th) (/ ky (sin kx))) (sin th)))
                                        double code(double kx, double ky, double th) {
                                        	double tmp;
                                        	if (ky <= 9.8e-30) {
                                        		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 <= 9.8d-30) 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 <= 9.8e-30) {
                                        		tmp = Math.sin(th) * (ky / Math.sin(kx));
                                        	} else {
                                        		tmp = Math.sin(th);
                                        	}
                                        	return tmp;
                                        }
                                        
                                        def code(kx, ky, th):
                                        	tmp = 0
                                        	if ky <= 9.8e-30:
                                        		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 <= 9.8e-30)
                                        		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 <= 9.8e-30)
                                        		tmp = sin(th) * (ky / sin(kx));
                                        	else
                                        		tmp = sin(th);
                                        	end
                                        	tmp_2 = tmp;
                                        end
                                        
                                        code[kx_, ky_, th_] := If[LessEqual[ky, 9.8e-30], 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 9.8 \cdot 10^{-30}:\\
                                        \;\;\;\;\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 < 9.79999999999999942e-30

                                          1. Initial program 88.0%

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

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

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

                                          if 9.79999999999999942e-30 < ky

                                          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. accelerator-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) \]
                                            11. 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) \]
                                            12. 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.f6435.6%

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

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

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

                                        Alternative 17: 32.7% accurate, 3.4× speedup?

                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 1.05 \cdot 10^{-29}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
                                        (FPCore (kx ky th)
                                         :precision binary64
                                         (if (<= ky 1.05e-29) (* ky (/ (sin th) (sin kx))) (sin th)))
                                        double code(double kx, double ky, double th) {
                                        	double tmp;
                                        	if (ky <= 1.05e-29) {
                                        		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 <= 1.05d-29) 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 <= 1.05e-29) {
                                        		tmp = ky * (Math.sin(th) / Math.sin(kx));
                                        	} else {
                                        		tmp = Math.sin(th);
                                        	}
                                        	return tmp;
                                        }
                                        
                                        def code(kx, ky, th):
                                        	tmp = 0
                                        	if ky <= 1.05e-29:
                                        		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 <= 1.05e-29)
                                        		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 <= 1.05e-29)
                                        		tmp = ky * (sin(th) / sin(kx));
                                        	else
                                        		tmp = sin(th);
                                        	end
                                        	tmp_2 = tmp;
                                        end
                                        
                                        code[kx_, ky_, th_] := If[LessEqual[ky, 1.05e-29], 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 1.05 \cdot 10^{-29}:\\
                                        \;\;\;\;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 < 1.04999999999999995e-29

                                          1. Initial program 88.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. accelerator-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) \]
                                            11. 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) \]
                                            12. 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.f6433.7%

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

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

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

                                            if 1.04999999999999995e-29 < ky

                                            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. accelerator-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) \]
                                              11. 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) \]
                                              12. 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.f6435.6%

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

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

                                          Alternative 18: 26.2% accurate, 6.2× speedup?

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

                                            1. Initial program 87.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. accelerator-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) \]
                                              11. 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) \]
                                              12. sin-lowering-sin.f6499.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(ky, kx\right), \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{/.f64}\left(1, \mathsf{sin.f64}\left(th\right)\right)\right)\right) \]
                                              9. Simplified23.2%

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

                                              if 1.60000000000000003e-86 < ky

                                              1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

                                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                                10. accelerator-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) \]
                                                11. 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) \]
                                                12. 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.f6434.2%

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

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

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

                                            Alternative 19: 25.4% accurate, 6.4× speedup?

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

                                              1. Initial program 87.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. accelerator-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) \]
                                                11. 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) \]
                                                12. sin-lowering-sin.f6499.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                if 2.24999999999999996e-88 < ky

                                                1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

                                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                                  10. accelerator-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) \]
                                                  11. 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) \]
                                                  12. 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.f6434.2%

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

                                                  \[\leadsto \color{blue}{\sin th} \]
                                              7. Recombined 2 regimes into one program.
                                              8. Final simplification24.5%

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

                                              Alternative 20: 25.2% accurate, 6.4× speedup?

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

                                                1. Initial program 87.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. accelerator-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) \]
                                                  11. 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) \]
                                                  12. sin-lowering-sin.f6499.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                    if 2.50000000000000021e-87 < ky

                                                    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

                                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                                      10. accelerator-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) \]
                                                      11. 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) \]
                                                      12. 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.f6434.2%

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

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

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

                                                  Alternative 21: 25.1% accurate, 6.4× speedup?

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

                                                    1. Initial program 87.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. accelerator-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) \]
                                                      11. 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) \]
                                                      12. sin-lowering-sin.f6499.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                        \[\leadsto \color{blue}{\frac{ky \cdot th}{\sin kx}} \]
                                                      8. 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.f6420.6%

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

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

                                                      if 6.50000000000000022e-84 < ky

                                                      1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

                                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                                        10. accelerator-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) \]
                                                        11. 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) \]
                                                        12. 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.f6434.2%

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

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

                                                    Alternative 22: 23.0% accurate, 6.7× speedup?

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

                                                      1. Initial program 87.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. accelerator-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) \]
                                                        11. 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) \]
                                                        12. sin-lowering-sin.f6499.6%

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

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

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

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

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

                                                          \[\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{sin.f64}\left(kx\right)\right)\right)\right) \]
                                                      7. Simplified53.0%

                                                        \[\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, \sin kx\right)} \]
                                                      8. Taylor expanded in kx around 0

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

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

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

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

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

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

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

                                                            \[\leadsto \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(\frac{ky}{kx}\right)\right) \]
                                                          7. unpow2N/A

                                                            \[\leadsto \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(\frac{ky}{kx}\right)\right) \]
                                                          8. *-lowering-*.f64N/A

                                                            \[\leadsto \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(\frac{ky}{kx}\right)\right) \]
                                                          9. /-lowering-/.f6417.1%

                                                            \[\leadsto \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(ky, \color{blue}{kx}\right)\right) \]
                                                        4. Simplified17.1%

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

                                                        if 4.90000000000000028e-88 < ky

                                                        1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

                                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                                          10. accelerator-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) \]
                                                          11. 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) \]
                                                          12. 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.f6434.2%

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

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

                                                      Alternative 23: 18.0% accurate, 39.4× speedup?

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

                                                        1. Initial program 87.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. accelerator-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) \]
                                                          11. 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) \]
                                                          12. sin-lowering-sin.f6499.6%

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

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

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

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

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

                                                            \[\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{sin.f64}\left(kx\right)\right)\right)\right) \]
                                                        7. Simplified53.0%

                                                          \[\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, \sin kx\right)} \]
                                                        8. Taylor expanded in kx around 0

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

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

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

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

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

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

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

                                                              \[\leadsto \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(\frac{ky}{kx}\right)\right) \]
                                                            7. unpow2N/A

                                                              \[\leadsto \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(\frac{ky}{kx}\right)\right) \]
                                                            8. *-lowering-*.f64N/A

                                                              \[\leadsto \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(\frac{ky}{kx}\right)\right) \]
                                                            9. /-lowering-/.f6417.1%

                                                              \[\leadsto \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(ky, \color{blue}{kx}\right)\right) \]
                                                          4. Simplified17.1%

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

                                                          if 2.7000000000000002e-80 < ky

                                                          1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

                                                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                                                            10. accelerator-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) \]
                                                            11. 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) \]
                                                            12. 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.f6434.2%

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

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

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

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

                                                          Alternative 24: 15.9% accurate, 59.0× speedup?

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

                                                            1. Initial program 88.1%

                                                              \[\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. accelerator-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) \]
                                                              11. 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) \]
                                                              12. 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.f6421.4%

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

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

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

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

                                                              if 12000 < kx

                                                              1. Initial program 99.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. accelerator-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) \]
                                                                11. 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) \]
                                                                12. 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 kx around 0

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

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

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

                                                                \[\leadsto \color{blue}{th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)} \]
                                                              9. Step-by-step derivation
                                                                1. *-lowering-*.f64N/A

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

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

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

                                                                  \[\leadsto \mathsf{*.f64}\left(th, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \left(th \cdot \color{blue}{th}\right)\right)\right)\right) \]
                                                                5. *-lowering-*.f645.8%

                                                                  \[\leadsto \mathsf{*.f64}\left(th, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(th, \color{blue}{th}\right)\right)\right)\right) \]
                                                              10. Simplified5.8%

                                                                \[\leadsto \color{blue}{th \cdot \left(1 + -0.16666666666666666 \cdot \left(th \cdot th\right)\right)} \]
                                                              11. Taylor expanded in th around inf

                                                                \[\leadsto \color{blue}{\frac{-1}{6} \cdot {th}^{3}} \]
                                                              12. Step-by-step derivation
                                                                1. *-lowering-*.f64N/A

                                                                  \[\leadsto \mathsf{*.f64}\left(\frac{-1}{6}, \color{blue}{\left({th}^{3}\right)}\right) \]
                                                                2. cube-multN/A

                                                                  \[\leadsto \mathsf{*.f64}\left(\frac{-1}{6}, \left(th \cdot \color{blue}{\left(th \cdot th\right)}\right)\right) \]
                                                                3. unpow2N/A

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

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

                                                                  \[\leadsto \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(th, \left(th \cdot \color{blue}{th}\right)\right)\right) \]
                                                                6. *-lowering-*.f649.3%

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

                                                                \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(th \cdot \left(th \cdot th\right)\right)} \]
                                                            10. Recombined 2 regimes into one program.
                                                            11. Add Preprocessing

                                                            Alternative 25: 13.7% accurate, 709.0× speedup?

                                                            \[\begin{array}{l} \\ th \end{array} \]
                                                            (FPCore (kx ky th) :precision binary64 th)
                                                            double code(double kx, double ky, double th) {
                                                            	return th;
                                                            }
                                                            
                                                            real(8) function code(kx, ky, th)
                                                                real(8), intent (in) :: kx
                                                                real(8), intent (in) :: ky
                                                                real(8), intent (in) :: th
                                                                code = th
                                                            end function
                                                            
                                                            public static double code(double kx, double ky, double th) {
                                                            	return th;
                                                            }
                                                            
                                                            def code(kx, ky, th):
                                                            	return th
                                                            
                                                            function code(kx, ky, th)
                                                            	return th
                                                            end
                                                            
                                                            function tmp = code(kx, ky, th)
                                                            	tmp = th;
                                                            end
                                                            
                                                            code[kx_, ky_, th_] := th
                                                            
                                                            \begin{array}{l}
                                                            
                                                            \\
                                                            th
                                                            \end{array}
                                                            
                                                            Derivation
                                                            1. Initial program 90.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. accelerator-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) \]
                                                              11. 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) \]
                                                              12. 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.f6418.4%

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

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

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

                                                                \[\leadsto \color{blue}{th} \]
                                                              2. Add Preprocessing

                                                              Reproduce

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