Toniolo and Linder, Equation (3b), real

Percentage Accurate: 94.4% → 99.7%
Time: 13.7s
Alternatives: 17
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 17 alternatives:

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

Initial Program: 94.4% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.4× speedup?

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

\\
\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th
\end{array}
Derivation
  1. Initial program 94.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. Step-by-step derivation
    1. associate-*r/N/A

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

      \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}} \]
    3. pow2N/A

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right), \color{blue}{\sin th}\right) \]
  6. Applied egg-rr99.7%

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

Alternative 2: 71.1% accurate, 1.3× speedup?

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

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

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

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


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

    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 th around 0

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

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

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

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

        if -0.110000000000000001 < (sin.f64 ky) < 0.0050000000000000001

        1. Initial program 89.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\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(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
        10. Simplified96.4%

          \[\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 \cdot \left(1 + \left(ky \cdot ky\right) \cdot -0.16666666666666666\right), \sin kx\right)} \]

        if 0.0050000000000000001 < (sin.f64 ky)

        1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 3: 71.0% accurate, 1.4× speedup?

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

        1. Initial program 99.6%

          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
        2. 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. Simplified50.9%

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

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

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

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

            1. Initial program 89.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 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}{\left(ky \cdot \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)\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{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)\right), \mathsf{sin.f64}\left(\color{blue}{kx}\right)\right)\right)\right) \]
              2. +-lowering-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

              if 0.0050000000000000001 < (sin.f64 ky)

              1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Alternative 4: 70.8% accurate, 1.4× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq -0.05:\\ \;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{elif}\;\sin ky \leq 0.09:\\ \;\;\;\;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.05)
               (* (sin ky) (/ th (hypot (sin ky) kx)))
               (if (<= (sin ky) 0.09) (* ky (/ (sin th) (hypot ky (sin kx)))) (sin th))))
            double code(double kx, double ky, double th) {
            	double tmp;
            	if (sin(ky) <= -0.05) {
            		tmp = sin(ky) * (th / hypot(sin(ky), kx));
            	} else if (sin(ky) <= 0.09) {
            		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.05) {
            		tmp = Math.sin(ky) * (th / Math.hypot(Math.sin(ky), kx));
            	} else if (Math.sin(ky) <= 0.09) {
            		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.05:
            		tmp = math.sin(ky) * (th / math.hypot(math.sin(ky), kx))
            	elif math.sin(ky) <= 0.09:
            		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.05)
            		tmp = Float64(sin(ky) * Float64(th / hypot(sin(ky), kx)));
            	elseif (sin(ky) <= 0.09)
            		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.05)
            		tmp = sin(ky) * (th / hypot(sin(ky), kx));
            	elseif (sin(ky) <= 0.09)
            		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.05], N[(N[Sin[ky], $MachinePrecision] * N[(th / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.09], 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.05:\\
            \;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
            
            \mathbf{elif}\;\sin ky \leq 0.09:\\
            \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
            
            \mathbf{else}:\\
            \;\;\;\;\sin th\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if (sin.f64 ky) < -0.050000000000000003

              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 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. Simplified50.9%

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

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

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

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

                  1. Initial program 89.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{*.f64}\left(ky, \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) \]
                    3. Step-by-step derivation
                      1. Simplified96.8%

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

                      if 0.089999999999999997 < (sin.f64 ky)

                      1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    Alternative 5: 71.1% accurate, 1.4× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq -0.05:\\ \;\;\;\;\frac{\sin th \cdot \left(6 - ky \cdot ky\right)}{ky \cdot ky}\\ \mathbf{elif}\;\sin ky \leq 0.09:\\ \;\;\;\;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.05)
                       (/ (* (sin th) (- 6.0 (* ky ky))) (* ky ky))
                       (if (<= (sin ky) 0.09) (* ky (/ (sin th) (hypot ky (sin kx)))) (sin th))))
                    double code(double kx, double ky, double th) {
                    	double tmp;
                    	if (sin(ky) <= -0.05) {
                    		tmp = (sin(th) * (6.0 - (ky * ky))) / (ky * ky);
                    	} else if (sin(ky) <= 0.09) {
                    		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.05) {
                    		tmp = (Math.sin(th) * (6.0 - (ky * ky))) / (ky * ky);
                    	} else if (Math.sin(ky) <= 0.09) {
                    		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.05:
                    		tmp = (math.sin(th) * (6.0 - (ky * ky))) / (ky * ky)
                    	elif math.sin(ky) <= 0.09:
                    		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.05)
                    		tmp = Float64(Float64(sin(th) * Float64(6.0 - Float64(ky * ky))) / Float64(ky * ky));
                    	elseif (sin(ky) <= 0.09)
                    		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.05)
                    		tmp = (sin(th) * (6.0 - (ky * ky))) / (ky * ky);
                    	elseif (sin(ky) <= 0.09)
                    		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.05], N[(N[(N[Sin[th], $MachinePrecision] * N[(6.0 - N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(ky * ky), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.09], 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.05:\\
                    \;\;\;\;\frac{\sin th \cdot \left(6 - ky \cdot ky\right)}{ky \cdot ky}\\
                    
                    \mathbf{elif}\;\sin ky \leq 0.09:\\
                    \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\sin th\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 3 regimes
                    2. if (sin.f64 ky) < -0.050000000000000003

                      1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \left({ky}^{3}\right)\right)\right) \]
                        6. cube-multN/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \left(ky \cdot \color{blue}{\left(ky \cdot ky\right)}\right)\right)\right) \]
                        7. unpow2N/A

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

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \mathsf{*.f64}\left(ky, \color{blue}{\left({ky}^{2}\right)}\right)\right)\right) \]
                        9. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \mathsf{*.f64}\left(ky, \left(ky \cdot \color{blue}{ky}\right)\right)\right)\right) \]
                        10. *-lowering-*.f644.5%

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \mathsf{*.f64}\left(ky, \mathsf{*.f64}\left(ky, \color{blue}{ky}\right)\right)\right)\right) \]
                      10. Simplified4.5%

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

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

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

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

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

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

                          \[\leadsto \mathsf{/.f64}\left(\left(-1 \cdot \left({ky}^{2} \cdot \sin th\right) + 6 \cdot \sin th\right), \left({\color{blue}{ky}}^{2}\right)\right) \]
                        6. associate-*r*N/A

                          \[\leadsto \mathsf{/.f64}\left(\left(\left(-1 \cdot {ky}^{2}\right) \cdot \sin th + 6 \cdot \sin th\right), \left({ky}^{2}\right)\right) \]
                        7. distribute-rgt-outN/A

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

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

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

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

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

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

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

                          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(-1, \mathsf{*.f64}\left(ky, ky\right)\right), 6\right)\right), \left(ky \cdot \color{blue}{ky}\right)\right) \]
                        15. *-lowering-*.f6423.1%

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

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

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

                      1. Initial program 89.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \mathsf{*.f64}\left(ky, \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) \]
                        3. Step-by-step derivation
                          1. Simplified96.8%

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

                          if 0.089999999999999997 < (sin.f64 ky)

                          1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        Alternative 6: 45.6% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \left({ky}^{3}\right)\right)\right) \]
                            6. cube-multN/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \left(ky \cdot \color{blue}{\left(ky \cdot ky\right)}\right)\right)\right) \]
                            7. unpow2N/A

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

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \mathsf{*.f64}\left(ky, \color{blue}{\left({ky}^{2}\right)}\right)\right)\right) \]
                            9. unpow2N/A

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

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{/.f64}\left(\left(-1 \cdot \left({ky}^{2} \cdot \sin th\right) + 6 \cdot \sin th\right), \left({\color{blue}{ky}}^{2}\right)\right) \]
                            6. associate-*r*N/A

                              \[\leadsto \mathsf{/.f64}\left(\left(\left(-1 \cdot {ky}^{2}\right) \cdot \sin th + 6 \cdot \sin th\right), \left({ky}^{2}\right)\right) \]
                            7. distribute-rgt-outN/A

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

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

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

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

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

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

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

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

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

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

                          if -0.10000000000000001 < (sin.f64 ky) < 5.00000000000000004e-36

                          1. Initial program 88.6%

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

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

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

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

                          if 5.00000000000000004e-36 < (sin.f64 ky)

                          1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

                        Alternative 7: 45.7% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \left({ky}^{3}\right)\right)\right) \]
                            6. cube-multN/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \left(ky \cdot \color{blue}{\left(ky \cdot ky\right)}\right)\right)\right) \]
                            7. unpow2N/A

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

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \mathsf{*.f64}\left(ky, \color{blue}{\left({ky}^{2}\right)}\right)\right)\right) \]
                            9. unpow2N/A

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

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{/.f64}\left(\left(-1 \cdot \left({ky}^{2} \cdot \sin th\right) + 6 \cdot \sin th\right), \left({\color{blue}{ky}}^{2}\right)\right) \]
                            6. associate-*r*N/A

                              \[\leadsto \mathsf{/.f64}\left(\left(\left(-1 \cdot {ky}^{2}\right) \cdot \sin th + 6 \cdot \sin th\right), \left({ky}^{2}\right)\right) \]
                            7. distribute-rgt-outN/A

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

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

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

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

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

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

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

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

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

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

                          if -0.10000000000000001 < (sin.f64 ky) < 5.0000000000000002e-28

                          1. Initial program 88.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 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.f6451.6%

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

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

                          if 5.0000000000000002e-28 < (sin.f64 ky)

                          1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

                        Alternative 8: 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 94.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. Add Preprocessing

                        Alternative 9: 45.7% accurate, 1.7× speedup?

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

                          1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \left({ky}^{3}\right)\right)\right) \]
                            6. cube-multN/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \left(ky \cdot \color{blue}{\left(ky \cdot ky\right)}\right)\right)\right) \]
                            7. unpow2N/A

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

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \mathsf{*.f64}\left(ky, \color{blue}{\left({ky}^{2}\right)}\right)\right)\right) \]
                            9. unpow2N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \mathsf{*.f64}\left(ky, \left(ky \cdot \color{blue}{ky}\right)\right)\right)\right) \]
                            10. *-lowering-*.f644.5%

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \mathsf{*.f64}\left(ky, \mathsf{*.f64}\left(ky, \color{blue}{ky}\right)\right)\right)\right) \]
                          10. Simplified4.5%

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

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

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

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

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

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

                              \[\leadsto \mathsf{/.f64}\left(\left(-1 \cdot \left({ky}^{2} \cdot \sin th\right) + 6 \cdot \sin th\right), \left({\color{blue}{ky}}^{2}\right)\right) \]
                            6. associate-*r*N/A

                              \[\leadsto \mathsf{/.f64}\left(\left(\left(-1 \cdot {ky}^{2}\right) \cdot \sin th + 6 \cdot \sin th\right), \left({ky}^{2}\right)\right) \]
                            7. distribute-rgt-outN/A

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(-1, \mathsf{*.f64}\left(ky, ky\right)\right), 6\right)\right), \left(ky \cdot \color{blue}{ky}\right)\right) \]
                            15. *-lowering-*.f6423.1%

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

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

                          if -0.050000000000000003 < (sin.f64 ky) < 5.00000000000000004e-36

                          1. Initial program 88.4%

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

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

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

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

                          if 5.00000000000000004e-36 < (sin.f64 ky)

                          1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

                        Alternative 10: 45.7% accurate, 1.7× speedup?

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

                          1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \left({ky}^{3}\right)\right)\right) \]
                            6. cube-multN/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \left(ky \cdot \color{blue}{\left(ky \cdot ky\right)}\right)\right)\right) \]
                            7. unpow2N/A

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

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \mathsf{*.f64}\left(ky, \color{blue}{\left({ky}^{2}\right)}\right)\right)\right) \]
                            9. unpow2N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \mathsf{*.f64}\left(ky, \left(ky \cdot \color{blue}{ky}\right)\right)\right)\right) \]
                            10. *-lowering-*.f644.5%

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), 6\right), \mathsf{*.f64}\left(ky, \mathsf{*.f64}\left(ky, \color{blue}{ky}\right)\right)\right)\right) \]
                          10. Simplified4.5%

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

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

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

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

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

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

                              \[\leadsto \mathsf{/.f64}\left(\left(-1 \cdot \left({ky}^{2} \cdot \sin th\right) + 6 \cdot \sin th\right), \left({\color{blue}{ky}}^{2}\right)\right) \]
                            6. associate-*r*N/A

                              \[\leadsto \mathsf{/.f64}\left(\left(\left(-1 \cdot {ky}^{2}\right) \cdot \sin th + 6 \cdot \sin th\right), \left({ky}^{2}\right)\right) \]
                            7. distribute-rgt-outN/A

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

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

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

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

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

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

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

                              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(-1, \mathsf{*.f64}\left(ky, ky\right)\right), 6\right)\right), \left(ky \cdot \color{blue}{ky}\right)\right) \]
                            15. *-lowering-*.f6423.1%

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

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

                          if -0.050000000000000003 < (sin.f64 ky) < 5.0000000000000002e-28

                          1. Initial program 88.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            if 5.0000000000000002e-28 < (sin.f64 ky)

                            1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

                          Alternative 11: 66.2% accurate, 1.7× speedup?

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

                            1. Initial program 94.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. Step-by-step derivation
                              1. associate-*r/N/A

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

                                \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}} \]
                              3. pow2N/A

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

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

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

                                \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right), \color{blue}{\sin th}\right) \]
                            6. Applied egg-rr99.7%

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

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

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

                              if 7.7999999999999999e-5 < th

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

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

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

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

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

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

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

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

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

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

                                  \[\leadsto \mathsf{*.f64}\left(ky, \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) \]
                                3. Step-by-step derivation
                                  1. Simplified66.8%

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

                                Alternative 12: 66.2% accurate, 1.7× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;th \leq 1.5 \cdot 10^{-5}:\\ \;\;\;\;\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 1.5e-5)
                                   (* (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 <= 1.5e-5) {
                                		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 <= 1.5e-5) {
                                		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 <= 1.5e-5:
                                		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 <= 1.5e-5)
                                		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 <= 1.5e-5)
                                		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, 1.5e-5], 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 1.5 \cdot 10^{-5}:\\
                                \;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 2 regimes
                                2. if th < 1.50000000000000004e-5

                                  1. Initial program 94.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 th around 0

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

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

                                    if 1.50000000000000004e-5 < th

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

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

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

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

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

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

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

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

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

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

                                        \[\leadsto \mathsf{*.f64}\left(ky, \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) \]
                                      3. Step-by-step derivation
                                        1. Simplified66.8%

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

                                      Alternative 13: 25.0% accurate, 6.4× speedup?

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

                                        1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                            \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\sin ky \cdot \sin 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{\sin ky \cdot \sin 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}{\sin ky \cdot \sin 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}{\sin ky \cdot \sin 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{\sin ky \cdot \sin 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(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                                          7. rem-exp-logN/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(\sin ky, e^{\log \sin kx}\right)\right)\right) \]
                                          8. 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(\sin ky, \color{blue}{\left(e^{\log \sin kx}\right)}\right)\right) \]
                                          9. sin-lowering-sin.f64N/A

                                            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(th\right)\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(e^{\color{blue}{\log \sin kx}}\right)\right)\right) \]
                                          10. rem-exp-logN/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(\mathsf{sin.f64}\left(ky\right), \sin kx\right)\right) \]
                                          11. sin-lowering-sin.f6496.3%

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

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

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

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

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

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

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

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

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

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

                                          if 7.8000000000000004e-60 < 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.f6437.5%

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

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

                                        Alternative 14: 23.9% accurate, 6.4× speedup?

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

                                          1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                            if 7.59999999999999989e-60 < 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.f6437.5%

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

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

                                          Alternative 15: 21.4% accurate, 6.7× speedup?

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

                                            1. Initial program 91.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                            if 3.09999999999999988e-254 < ky

                                            1. Initial program 97.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          Alternative 16: 15.2% accurate, 59.0× speedup?

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

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

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

                                              \[\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-*.f649.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. Simplified9.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.0%

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

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

                                            if 5.4000000000000003e-70 < 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.5%

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

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

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

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

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

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

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

                                            Alternative 17: 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 94.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 kx around 0

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

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

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

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

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

                                              Reproduce

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