Toniolo and Linder, Equation (3b), real

Percentage Accurate: 94.0% → 99.7%
Time: 14.4s
Alternatives: 24
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 24 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.0% 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 95.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right), \color{blue}{\sin ky}\right)\right) \]
    7. +-commutativeN/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), \sin ky\right)\right) \]
    8. hypot-defineN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\left(\mathsf{hypot}\left(\sin ky, \sin kx\right)\right), \sin \color{blue}{ky}\right)\right) \]
    9. hypot-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) \]
    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), \sin kx\right), \sin ky\right)\right) \]
    11. 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) \]
    12. 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. Add Preprocessing

Alternative 2: 71.7% accurate, 1.3× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;\sin th\\


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

    1. Initial program 99.6%

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \sin ky\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
      6. sin-lowering-sin.f6499.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. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right), \color{blue}{\sin ky}\right)\right) \]
      7. +-commutativeN/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), \sin ky\right)\right) \]
      8. hypot-defineN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\left(\mathsf{hypot}\left(\sin ky, \sin kx\right)\right), \sin \color{blue}{ky}\right)\right) \]
      9. hypot-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) \]
      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), \sin kx\right), \sin ky\right)\right) \]
      11. 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) \]
      12. 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 th around 0

      \[\leadsto \mathsf{/.f64}\left(\color{blue}{th}, \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) \]
    9. Step-by-step derivation
      1. Simplified58.4%

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

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

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

        if -5.0000000000000001e-4 < (sin.f64 ky) < 2e-3

        1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
        4. Add Preprocessing
        5. Taylor expanded in 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}{\left(ky \cdot \left(1 + {ky}^{2} \cdot \left(\frac{1}{120} \cdot {ky}^{2} - \frac{1}{6}\right)\right)\right)}, \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. *-lowering-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if 2e-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. hypot-defineN/A

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

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

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

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

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

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

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

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

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

        Alternative 3: 71.7% accurate, 1.4× speedup?

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

          1. Initial program 99.6%

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \sin ky\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
            6. sin-lowering-sin.f6499.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. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right), \color{blue}{\sin ky}\right)\right) \]
            7. +-commutativeN/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), \sin ky\right)\right) \]
            8. hypot-defineN/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\left(\mathsf{hypot}\left(\sin ky, \sin kx\right)\right), \sin \color{blue}{ky}\right)\right) \]
            9. hypot-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) \]
            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), \sin kx\right), \sin ky\right)\right) \]
            11. 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) \]
            12. 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 th around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{th}, \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) \]
          9. Step-by-step derivation
            1. Simplified58.4%

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

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

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

              if -5.0000000000000001e-4 < (sin.f64 ky) < 2e-3

              1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
              4. Add Preprocessing
              5. Taylor expanded in 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}{\left(ky \cdot \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)\right)}, \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. *-lowering-*.f64N/A

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

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

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

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

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

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

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

                if 2e-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. hypot-defineN/A

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

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

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

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

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

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

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

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

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

              Alternative 4: 71.8% accurate, 1.4× speedup?

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

                1. Initial program 99.6%

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

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

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

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

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

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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(kx\right), \sin ky\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                  6. sin-lowering-sin.f6499.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. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right), \color{blue}{\sin ky}\right)\right) \]
                  7. +-commutativeN/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), \sin ky\right)\right) \]
                  8. hypot-defineN/A

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\left(\mathsf{hypot}\left(\sin ky, \sin kx\right)\right), \sin \color{blue}{ky}\right)\right) \]
                  9. hypot-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) \]
                  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), \sin kx\right), \sin ky\right)\right) \]
                  11. 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) \]
                  12. 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 th around 0

                  \[\leadsto \mathsf{/.f64}\left(\color{blue}{th}, \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) \]
                9. Step-by-step derivation
                  1. Simplified58.4%

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

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

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

                    if -5.0000000000000001e-4 < (sin.f64 ky) < 2e-3

                    1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
                    4. Add Preprocessing
                    5. Taylor expanded in 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. Simplified98.9%

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

                        if 2e-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. hypot-defineN/A

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

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

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

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

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

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

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

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

                      Alternative 5: 66.6% accurate, 1.4× speedup?

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

                        1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
                        4. Add Preprocessing
                        5. Taylor expanded in 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.f6410.1%

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

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

                        if -5.0000000000000001e-4 < (sin.f64 ky) < 2e-3

                        1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
                        4. Add Preprocessing
                        5. Taylor expanded in 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. Simplified98.9%

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

                            if 2e-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. hypot-defineN/A

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

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

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

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

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

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

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

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

                          Alternative 6: 43.5% accurate, 1.4× speedup?

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

                            1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \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. Simplified60.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  if -0.10000000000000001 < (sin.f64 kx) < 2.00000000000000003e-119

                                  1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                    13. sin-lowering-sin.f6499.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.f6440.2%

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

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

                                  if 2.00000000000000003e-119 < (sin.f64 kx)

                                  1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right), \color{blue}{\sin ky}\right)\right) \]
                                    7. +-commutativeN/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), \sin ky\right)\right) \]
                                    8. hypot-defineN/A

                                      \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\left(\mathsf{hypot}\left(\sin ky, \sin kx\right)\right), \sin \color{blue}{ky}\right)\right) \]
                                    9. hypot-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) \]
                                    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), \sin kx\right), \sin ky\right)\right) \]
                                    11. 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) \]
                                    12. sin-lowering-sin.f6499.5%

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

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

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

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

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

                                Alternative 7: 43.5% accurate, 1.4× speedup?

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

                                  1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \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. Simplified60.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                        if -0.10000000000000001 < (sin.f64 kx) < 2.00000000000000003e-119

                                        1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

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

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

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                          13. sin-lowering-sin.f6499.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.f6440.2%

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

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

                                        if 2.00000000000000003e-119 < (sin.f64 kx)

                                        1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
                                        4. Add Preprocessing
                                        5. Taylor expanded in 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.f6454.1%

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

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

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

                                      Alternative 8: 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 95.1%

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

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

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

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

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

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

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

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

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

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

                                      Alternative 9: 99.6% accurate, 1.4× speedup?

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

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

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

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

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

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

                                      Alternative 10: 66.1% accurate, 1.7× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;th \leq 0.37:\\ \;\;\;\;\frac{th \cdot \left(1 + -0.16666666666666666 \cdot \left(th \cdot th\right)\right)}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}}\\ \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.37)
                                         (/
                                          (* th (+ 1.0 (* -0.16666666666666666 (* th th))))
                                          (/ (hypot (sin ky) (sin kx)) (sin ky)))
                                         (* ky (/ (sin th) (hypot ky (sin kx))))))
                                      double code(double kx, double ky, double th) {
                                      	double tmp;
                                      	if (th <= 0.37) {
                                      		tmp = (th * (1.0 + (-0.16666666666666666 * (th * th)))) / (hypot(sin(ky), 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 <= 0.37) {
                                      		tmp = (th * (1.0 + (-0.16666666666666666 * (th * th)))) / (Math.hypot(Math.sin(ky), 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 <= 0.37:
                                      		tmp = (th * (1.0 + (-0.16666666666666666 * (th * th)))) / (math.hypot(math.sin(ky), 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 <= 0.37)
                                      		tmp = Float64(Float64(th * Float64(1.0 + Float64(-0.16666666666666666 * Float64(th * th)))) / Float64(hypot(sin(ky), 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 <= 0.37)
                                      		tmp = (th * (1.0 + (-0.16666666666666666 * (th * th)))) / (hypot(sin(ky), 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, 0.37], N[(N[(th * N[(1.0 + N[(-0.16666666666666666 * N[(th * th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $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.37:\\
                                      \;\;\;\;\frac{th \cdot \left(1 + -0.16666666666666666 \cdot \left(th \cdot th\right)\right)}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}}\\
                                      
                                      \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.37

                                        1. Initial program 96.2%

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

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

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

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

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

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

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

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

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

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right), \color{blue}{\sin ky}\right)\right) \]
                                          7. +-commutativeN/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), \sin ky\right)\right) \]
                                          8. hypot-defineN/A

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\left(\mathsf{hypot}\left(\sin ky, \sin kx\right)\right), \sin \color{blue}{ky}\right)\right) \]
                                          9. hypot-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) \]
                                          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), \sin kx\right), \sin ky\right)\right) \]
                                          11. 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) \]
                                          12. 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 th around 0

                                          \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left(th \cdot \left(1 + \frac{-1}{6} \cdot {th}^{2}\right)\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) \]
                                        9. Step-by-step derivation
                                          1. *-lowering-*.f64N/A

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

                                            \[\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(\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) \]
                                        10. Simplified67.9%

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

                                        if 0.37 < th

                                        1. Initial program 92.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. hypot-defineN/A

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

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

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

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

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

                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \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. Simplified55.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. Simplified64.4%

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

                                          Alternative 11: 66.1% accurate, 1.7× speedup?

                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;th \leq 0.37:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \left(th \cdot \left(1 + -0.16666666666666666 \cdot \left(th \cdot th\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \end{array} \end{array} \]
                                          (FPCore (kx ky th)
                                           :precision binary64
                                           (if (<= th 0.37)
                                             (*
                                              (/ (sin ky) (hypot (sin kx) (sin ky)))
                                              (* 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.37) {
                                          		tmp = (sin(ky) / hypot(sin(kx), sin(ky))) * (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.37) {
                                          		tmp = (Math.sin(ky) / Math.hypot(Math.sin(kx), Math.sin(ky))) * (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.37:
                                          		tmp = (math.sin(ky) / math.hypot(math.sin(kx), math.sin(ky))) * (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.37)
                                          		tmp = Float64(Float64(sin(ky) / hypot(sin(kx), sin(ky))) * Float64(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.37)
                                          		tmp = (sin(ky) / hypot(sin(kx), sin(ky))) * (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.37], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[(th * N[(1.0 + N[(-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.37:\\
                                          \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \left(th \cdot \left(1 + -0.16666666666666666 \cdot \left(th \cdot th\right)\right)\right)\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
                                          
                                          
                                          \end{array}
                                          \end{array}
                                          
                                          Derivation
                                          1. Split input into 2 regimes
                                          2. if th < 0.37

                                            1. Initial program 96.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                            if 0.37 < th

                                            1. Initial program 92.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. hypot-defineN/A

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

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

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

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

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

                                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \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. Simplified55.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. Simplified64.4%

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

                                              Alternative 12: 66.1% accurate, 1.7× speedup?

                                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;th \leq 0.37:\\ \;\;\;\;\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.37)
                                                 (*
                                                  (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.37) {
                                              		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.37) {
                                              		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.37:
                                              		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.37)
                                              		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.37)
                                              		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.37], 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.37:\\
                                              \;\;\;\;\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.37

                                                1. Initial program 96.2%

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

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

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

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

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

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

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

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

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

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

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

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

                                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                                  13. sin-lowering-sin.f6499.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-*.f6467.8%

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

                                                  \[\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.37 < th

                                                1. Initial program 92.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. hypot-defineN/A

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

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

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

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

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

                                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \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. Simplified55.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. Simplified64.4%

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

                                                  Alternative 13: 41.2% accurate, 1.7× speedup?

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

                                                    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \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. Simplified60.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                          if -0.10000000000000001 < (sin.f64 kx) < 4.00000000000000005e-119

                                                          1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

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

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

                                                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                                            13. sin-lowering-sin.f6499.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.f6440.2%

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

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

                                                          if 4.00000000000000005e-119 < (sin.f64 kx)

                                                          1. Initial program 99.5%

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

                                                            \[\leadsto \mathsf{*.f64}\left(\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.f6445.6%

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

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

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

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

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

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

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

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

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

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

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

                                                        Alternative 14: 66.2% accurate, 1.7× speedup?

                                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;th \leq 0.37:\\ \;\;\;\;\frac{th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}}\\ \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.37)
                                                           (/ th (/ (hypot (sin ky) (sin kx)) (sin ky)))
                                                           (* ky (/ (sin th) (hypot ky (sin kx))))))
                                                        double code(double kx, double ky, double th) {
                                                        	double tmp;
                                                        	if (th <= 0.37) {
                                                        		tmp = th / (hypot(sin(ky), 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 <= 0.37) {
                                                        		tmp = th / (Math.hypot(Math.sin(ky), 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 <= 0.37:
                                                        		tmp = th / (math.hypot(math.sin(ky), 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 <= 0.37)
                                                        		tmp = Float64(th / Float64(hypot(sin(ky), 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 <= 0.37)
                                                        		tmp = th / (hypot(sin(ky), 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, 0.37], N[(th / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[ky], $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.37:\\
                                                        \;\;\;\;\frac{th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}}\\
                                                        
                                                        \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.37

                                                          1. Initial program 96.2%

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

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

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

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

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

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

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

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

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

                                                              \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right), \color{blue}{\sin ky}\right)\right) \]
                                                            7. +-commutativeN/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), \sin ky\right)\right) \]
                                                            8. hypot-defineN/A

                                                              \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\left(\mathsf{hypot}\left(\sin ky, \sin kx\right)\right), \sin \color{blue}{ky}\right)\right) \]
                                                            9. hypot-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) \]
                                                            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), \sin kx\right), \sin ky\right)\right) \]
                                                            11. 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) \]
                                                            12. 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 th around 0

                                                            \[\leadsto \mathsf{/.f64}\left(\color{blue}{th}, \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) \]
                                                          9. Step-by-step derivation
                                                            1. Simplified68.1%

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

                                                            if 0.37 < th

                                                            1. Initial program 92.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. hypot-defineN/A

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

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

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

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

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

                                                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \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. Simplified55.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. Simplified64.4%

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

                                                              Alternative 15: 66.2% accurate, 1.7× speedup?

                                                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;th \leq 0.37:\\ \;\;\;\;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 0.37)
                                                                 (* 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 <= 0.37) {
                                                              		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 <= 0.37) {
                                                              		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 <= 0.37:
                                                              		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 <= 0.37)
                                                              		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 <= 0.37)
                                                              		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, 0.37], 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 0.37:\\
                                                              \;\;\;\;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 < 0.37

                                                                1. Initial program 96.2%

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

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

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

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

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

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

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

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

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

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

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

                                                                  if 0.37 < th

                                                                  1. Initial program 92.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. hypot-defineN/A

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

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

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

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

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

                                                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \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. Simplified55.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. Simplified64.4%

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

                                                                      \[\leadsto \begin{array}{l} \mathbf{if}\;th \leq 0.37:\\ \;\;\;\;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 16: 66.1% accurate, 1.7× speedup?

                                                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;th \leq 0.37:\\ \;\;\;\;\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.37)
                                                                       (* (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.37) {
                                                                    		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.37) {
                                                                    		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.37:
                                                                    		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.37)
                                                                    		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.37)
                                                                    		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.37], 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.37:\\
                                                                    \;\;\;\;\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.37

                                                                      1. Initial program 96.2%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                                                        13. sin-lowering-sin.f6499.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.0%

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

                                                                        if 0.37 < th

                                                                        1. Initial program 92.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. hypot-defineN/A

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

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

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

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

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

                                                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \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. Simplified55.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. Simplified64.4%

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

                                                                          Alternative 17: 32.7% accurate, 3.4× speedup?

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

                                                                            1. Initial program 93.6%

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

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

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

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

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

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

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

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

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

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

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

                                                                            if 8.20000000000000025e-36 < ky

                                                                            1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                          Alternative 18: 25.8% accurate, 6.4× speedup?

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

                                                                            1. Initial program 93.3%

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

                                                                              \[\leadsto \mathsf{*.f64}\left(\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.f6432.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                            if 6.49999999999999951e-69 < ky

                                                                            1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                          Alternative 19: 25.8% accurate, 6.4× speedup?

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

                                                                            1. Initial program 93.3%

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

                                                                              \[\leadsto \mathsf{*.f64}\left(\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.f6432.2%

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

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

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

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

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

                                                                            if 8.8000000000000001e-69 < ky

                                                                            1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                          Alternative 20: 27.0% accurate, 6.4× speedup?

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

                                                                            1. Initial program 93.3%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                                                              13. sin-lowering-sin.f6499.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.f6425.5%

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

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

                                                                            if 2.35e-88 < kx

                                                                            1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

                                                                                \[\leadsto \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{/.f64}\left(\sin kx, \color{blue}{ky}\right)\right) \]
                                                                              7. 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) \]
                                                                            7. Applied egg-rr31.7%

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

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

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

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

                                                                          Alternative 21: 25.0% accurate, 6.7× speedup?

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

                                                                            1. Initial program 93.5%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                                                              13. sin-lowering-sin.f6499.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.f6425.9%

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

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

                                                                            if 2.1999999999999999e-60 < kx

                                                                            1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                                                              13. sin-lowering-sin.f6499.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.f649.0%

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

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

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

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

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

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

                                                                          Alternative 22: 15.5% accurate, 50.6× speedup?

                                                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 2.2 \cdot 10^{-88}:\\ \;\;\;\;th \cdot \left(1 + -0.16666666666666666 \cdot \left(th \cdot th\right)\right)\\ \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 2.2e-88)
                                                                             (* th (+ 1.0 (* -0.16666666666666666 (* th th))))
                                                                             (* -0.16666666666666666 (* th (* th th)))))
                                                                          double code(double kx, double ky, double th) {
                                                                          	double tmp;
                                                                          	if (kx <= 2.2e-88) {
                                                                          		tmp = th * (1.0 + (-0.16666666666666666 * (th * 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 <= 2.2d-88) then
                                                                                  tmp = th * (1.0d0 + ((-0.16666666666666666d0) * (th * 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 <= 2.2e-88) {
                                                                          		tmp = th * (1.0 + (-0.16666666666666666 * (th * th)));
                                                                          	} else {
                                                                          		tmp = -0.16666666666666666 * (th * (th * th));
                                                                          	}
                                                                          	return tmp;
                                                                          }
                                                                          
                                                                          def code(kx, ky, th):
                                                                          	tmp = 0
                                                                          	if kx <= 2.2e-88:
                                                                          		tmp = th * (1.0 + (-0.16666666666666666 * (th * th)))
                                                                          	else:
                                                                          		tmp = -0.16666666666666666 * (th * (th * th))
                                                                          	return tmp
                                                                          
                                                                          function code(kx, ky, th)
                                                                          	tmp = 0.0
                                                                          	if (kx <= 2.2e-88)
                                                                          		tmp = Float64(th * Float64(1.0 + Float64(-0.16666666666666666 * Float64(th * 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 <= 2.2e-88)
                                                                          		tmp = th * (1.0 + (-0.16666666666666666 * (th * th)));
                                                                          	else
                                                                          		tmp = -0.16666666666666666 * (th * (th * th));
                                                                          	end
                                                                          	tmp_2 = tmp;
                                                                          end
                                                                          
                                                                          code[kx_, ky_, th_] := If[LessEqual[kx, 2.2e-88], N[(th * N[(1.0 + N[(-0.16666666666666666 * N[(th * th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.16666666666666666 * N[(th * N[(th * th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                                                          
                                                                          \begin{array}{l}
                                                                          
                                                                          \\
                                                                          \begin{array}{l}
                                                                          \mathbf{if}\;kx \leq 2.2 \cdot 10^{-88}:\\
                                                                          \;\;\;\;th \cdot \left(1 + -0.16666666666666666 \cdot \left(th \cdot th\right)\right)\\
                                                                          
                                                                          \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 < 2.20000000000000005e-88

                                                                            1. Initial program 93.3%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                                                              13. sin-lowering-sin.f6499.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.f6425.5%

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

                                                                              \[\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-*.f6411.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. Simplified11.8%

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

                                                                            if 2.20000000000000005e-88 < kx

                                                                            1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                                                              13. sin-lowering-sin.f6499.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.f6411.3%

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

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

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

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

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

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

                                                                          Alternative 23: 15.7% accurate, 59.0× speedup?

                                                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 1.2 \cdot 10^{-88}:\\ \;\;\;\;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 1.2e-88) th (* -0.16666666666666666 (* th (* th th)))))
                                                                          double code(double kx, double ky, double th) {
                                                                          	double tmp;
                                                                          	if (kx <= 1.2e-88) {
                                                                          		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 <= 1.2d-88) 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 <= 1.2e-88) {
                                                                          		tmp = th;
                                                                          	} else {
                                                                          		tmp = -0.16666666666666666 * (th * (th * th));
                                                                          	}
                                                                          	return tmp;
                                                                          }
                                                                          
                                                                          def code(kx, ky, th):
                                                                          	tmp = 0
                                                                          	if kx <= 1.2e-88:
                                                                          		tmp = th
                                                                          	else:
                                                                          		tmp = -0.16666666666666666 * (th * (th * th))
                                                                          	return tmp
                                                                          
                                                                          function code(kx, ky, th)
                                                                          	tmp = 0.0
                                                                          	if (kx <= 1.2e-88)
                                                                          		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 <= 1.2e-88)
                                                                          		tmp = th;
                                                                          	else
                                                                          		tmp = -0.16666666666666666 * (th * (th * th));
                                                                          	end
                                                                          	tmp_2 = tmp;
                                                                          end
                                                                          
                                                                          code[kx_, ky_, th_] := If[LessEqual[kx, 1.2e-88], th, N[(-0.16666666666666666 * N[(th * N[(th * th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                                                          
                                                                          \begin{array}{l}
                                                                          
                                                                          \\
                                                                          \begin{array}{l}
                                                                          \mathbf{if}\;kx \leq 1.2 \cdot 10^{-88}:\\
                                                                          \;\;\;\;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 < 1.2e-88

                                                                            1. Initial program 93.3%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                                                              13. sin-lowering-sin.f6499.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.f6425.5%

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

                                                                              \[\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 1.2e-88 < kx

                                                                              1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                                                                                13. sin-lowering-sin.f6499.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.f6411.3%

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

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

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

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

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

                                                                                \[\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 24: 14.0% 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 95.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. hypot-defineN/A

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

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

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

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

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

                                                                              \[\leadsto \color{blue}{\sin th} \]
                                                                            6. Step-by-step derivation
                                                                              1. sin-lowering-sin.f6421.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. Simplified11.2%

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

                                                                              Reproduce

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