Toniolo and Linder, Equation (3b), real

Percentage Accurate: 94.1% → 99.7%
Time: 13.8s
Alternatives: 20
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 20 alternatives:

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

Initial Program: 94.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 42.9% accurate, 1.1× speedup?

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

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

\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-117}:\\
\;\;\;\;\sin th \cdot \left(1 + \frac{\frac{-0.5 \cdot \left(kx \cdot kx\right)}{ky}}{ky}\right)\\

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

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


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -0.0400000000000000008 < (sin.f64 kx) < 2.00000000000000006e-117

      1. Initial program 85.7%

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(kx, kx\right)\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
      5. Simplified40.1%

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

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

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

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

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

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

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

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

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

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

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

      if 2.00000000000000006e-117 < (sin.f64 kx) < 1.00000000000000001e-50

      1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

          if 1.00000000000000001e-50 < (sin.f64 kx)

          1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 3: 42.9% accurate, 1.1× speedup?

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

          1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if -0.0400000000000000008 < (sin.f64 kx) < 2.00000000000000006e-117

            1. Initial program 85.7%

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(kx, kx\right)\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
            5. Simplified40.1%

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

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

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

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

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

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

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

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

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

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

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

            if 2.00000000000000006e-117 < (sin.f64 kx) < 1.00000000000000001e-50

            1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

                if 1.00000000000000001e-50 < (sin.f64 kx)

                1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              Alternative 4: 77.1% accurate, 1.2× speedup?

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

                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. Simplified48.0%

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

                  if -0.0100000000000000002 < (sin.f64 ky) < 1.00000000000000005e-4

                  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}{ky}, \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                  6. Step-by-step derivation
                    1. Simplified99.6%

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

                    if 1.00000000000000005e-4 < (sin.f64 ky)

                    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 5: 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 93.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 6: 64.2% accurate, 1.7× speedup?

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

                    1. Initial program 92.2%

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

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

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

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

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

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

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

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

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

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

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

                      if 0.0135999999999999992 < ky < 8.79999999999999945e163

                      1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

                        if 8.79999999999999945e163 < ky

                        1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 0.0136:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin kx, ky\right)}\\ \mathbf{elif}\;ky \leq 8.8 \cdot 10^{+163}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(kx, \sin ky\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \end{array} \]
                        9. Add Preprocessing

                        Alternative 7: 64.2% accurate, 1.7× speedup?

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

                          1. Initial program 92.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 ky around 0

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

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

                            if 0.0074999999999999997 < ky < 5.6000000000000004e164

                            1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

                              if 5.6000000000000004e164 < ky

                              1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 0.0075:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \mathbf{elif}\;ky \leq 5.6 \cdot 10^{+164}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(kx, \sin ky\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \end{array} \]
                              9. Add Preprocessing

                              Alternative 8: 64.2% accurate, 1.7× speedup?

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

                                1. Initial program 92.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 ky around 0

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

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

                                  if 0.0019499999999999999 < ky < 4.80000000000000018e162

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

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

                                    if 4.80000000000000018e162 < ky

                                    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    Alternative 9: 56.3% accurate, 1.7× speedup?

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

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

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

                                        if 3.8e5 < th < 1.0800000000000001e275

                                        1. Initial program 94.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.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.f6429.5%

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

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

                                        if 1.0800000000000001e275 < th

                                        1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      Alternative 10: 31.1% accurate, 2.2× speedup?

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

                                        1. Initial program 91.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(kx, \frac{-1}{2}\right), \mathsf{sin.f64}\left(ky\right)\right), \mathsf{/.f64}\left(kx, \sin ky\right)\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                          10. sin-lowering-sin.f6429.1%

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

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

                                        if 3.2e-115 < kx < 5.99999999999999975e-46

                                        1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                            if 5.99999999999999975e-46 < kx

                                            1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          Alternative 11: 32.6% accurate, 2.2× speedup?

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

                                            1. Initial program 91.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                            if 1.2000000000000001e-114 < kx < 8.4999999999999999e-47

                                            1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                if 8.4999999999999999e-47 < kx

                                                1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                              Alternative 12: 31.9% accurate, 2.3× speedup?

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

                                                1. Initial program 91.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                if 1.34999999999999998e-113 < kx

                                                1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                              Alternative 13: 33.6% accurate, 3.1× speedup?

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

                                                1. Initial program 90.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                if 9.9999999999999999e-161 < (sin.f64 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.f6452.0%

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

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

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

                                              Alternative 14: 33.6% accurate, 3.2× speedup?

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

                                                1. Initial program 90.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                if 9.9999999999999999e-161 < (sin.f64 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.f6452.0%

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

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

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

                                              Alternative 15: 33.6% accurate, 3.3× speedup?

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

                                                1. Initial program 90.3%

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

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

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

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

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

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

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

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

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

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

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

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

                                                if 9.9999999999999999e-161 < (sin.f64 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.f6452.0%

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

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

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

                                              Alternative 16: 30.7% accurate, 3.4× speedup?

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

                                                1. Initial program 91.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                if 1.39999999999999989e-109 < kx

                                                1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

                                              Alternative 17: 26.7% accurate, 6.4× speedup?

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

                                                1. Initial program 90.0%

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

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

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

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

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

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

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

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

                                                if 2.29999999999999985e-160 < 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.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.f6437.1%

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

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

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

                                              Alternative 18: 24.5% accurate, 6.7× speedup?

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

                                                1. Initial program 92.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.f6429.0%

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

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

                                                if 3.09999999999999975e46 < kx

                                                1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                    \[\leadsto {th}^{3} \cdot \color{blue}{\frac{-1}{6}} \]
                                                  2. cube-multN/A

                                                    \[\leadsto \left(th \cdot \left(th \cdot th\right)\right) \cdot \frac{-1}{6} \]
                                                  3. unpow2N/A

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

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

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

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

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

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

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

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

                                              Alternative 19: 15.4% accurate, 59.0× speedup?

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

                                                1. Initial program 91.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                  if 1.25e-53 < kx

                                                  1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                      \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                                                  7. Simplified8.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-*.f644.3%

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

                                                    \[\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. *-commutativeN/A

                                                      \[\leadsto {th}^{3} \cdot \color{blue}{\frac{-1}{6}} \]
                                                    2. cube-multN/A

                                                      \[\leadsto \left(th \cdot \left(th \cdot th\right)\right) \cdot \frac{-1}{6} \]
                                                    3. unpow2N/A

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

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

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

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

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

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

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

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

                                                Alternative 20: 13.3% 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 93.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                  Reproduce

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