Toniolo and Linder, Equation (3b), real

Percentage Accurate: 94.0% → 99.7%
Time: 13.8s
Alternatives: 24
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 24 alternatives:

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

Initial Program: 94.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.4× speedup?

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

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

    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
    3. unpow2N/A

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

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

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

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

Alternative 2: 71.5% accurate, 1.3× speedup?

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

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

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

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


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

    1. Initial program 99.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
      3. unpow2N/A

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

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

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

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

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

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

        if -0.0200000000000000004 < (sin.f64 ky) < 0.012

        1. Initial program 92.0%

          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
          3. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if 0.012 < (sin.f64 ky)

        1. Initial program 99.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 \color{blue}{\sin th} \]
        4. Step-by-step derivation
          1. sin-lowering-sin.f6462.5%

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

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

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

      Alternative 3: 71.4% accurate, 1.3× speedup?

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

        1. Initial program 99.7%

          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
          3. unpow2N/A

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

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

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

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

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

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

            if -0.0200000000000000004 < (sin.f64 ky) < 0.012

            1. Initial program 92.0%

              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
            2. Add Preprocessing
            3. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
              3. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if 0.012 < (sin.f64 ky)

            1. Initial program 99.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 \color{blue}{\sin th} \]
            4. Step-by-step derivation
              1. sin-lowering-sin.f6462.5%

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

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

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

          Alternative 4: 71.3% accurate, 1.3× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq -0.02:\\ \;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{elif}\;\sin ky \leq 0.012:\\ \;\;\;\;\sin th \cdot \frac{ky \cdot \left(1 + \left(ky \cdot ky\right) \cdot \left(-0.16666666666666666 + 0.008333333333333333 \cdot \left(ky \cdot ky\right)\right)\right)}{\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.02)
             (* th (/ (sin ky) (hypot (sin ky) kx)))
             (if (<= (sin ky) 0.012)
               (*
                (sin th)
                (/
                 (*
                  ky
                  (+
                   1.0
                   (*
                    (* ky ky)
                    (+ -0.16666666666666666 (* 0.008333333333333333 (* ky ky))))))
                 (hypot ky (sin kx))))
               (sin th))))
          double code(double kx, double ky, double th) {
          	double tmp;
          	if (sin(ky) <= -0.02) {
          		tmp = th * (sin(ky) / hypot(sin(ky), kx));
          	} else if (sin(ky) <= 0.012) {
          		tmp = sin(th) * ((ky * (1.0 + ((ky * ky) * (-0.16666666666666666 + (0.008333333333333333 * (ky * ky)))))) / 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.02) {
          		tmp = th * (Math.sin(ky) / Math.hypot(Math.sin(ky), kx));
          	} else if (Math.sin(ky) <= 0.012) {
          		tmp = Math.sin(th) * ((ky * (1.0 + ((ky * ky) * (-0.16666666666666666 + (0.008333333333333333 * (ky * ky)))))) / 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.02:
          		tmp = th * (math.sin(ky) / math.hypot(math.sin(ky), kx))
          	elif math.sin(ky) <= 0.012:
          		tmp = math.sin(th) * ((ky * (1.0 + ((ky * ky) * (-0.16666666666666666 + (0.008333333333333333 * (ky * ky)))))) / 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.02)
          		tmp = Float64(th * Float64(sin(ky) / hypot(sin(ky), kx)));
          	elseif (sin(ky) <= 0.012)
          		tmp = Float64(sin(th) * Float64(Float64(ky * Float64(1.0 + Float64(Float64(ky * ky) * Float64(-0.16666666666666666 + Float64(0.008333333333333333 * Float64(ky * ky)))))) / 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.02)
          		tmp = th * (sin(ky) / hypot(sin(ky), kx));
          	elseif (sin(ky) <= 0.012)
          		tmp = sin(th) * ((ky * (1.0 + ((ky * ky) * (-0.16666666666666666 + (0.008333333333333333 * (ky * ky)))))) / hypot(ky, sin(kx)));
          	else
          		tmp = sin(th);
          	end
          	tmp_2 = tmp;
          end
          
          code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], N[(th * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.012], N[(N[Sin[th], $MachinePrecision] * N[(N[(ky * N[(1.0 + N[(N[(ky * ky), $MachinePrecision] * N[(-0.16666666666666666 + N[(0.008333333333333333 * N[(ky * ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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.02:\\
          \;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
          
          \mathbf{elif}\;\sin ky \leq 0.012:\\
          \;\;\;\;\sin th \cdot \frac{ky \cdot \left(1 + \left(ky \cdot ky\right) \cdot \left(-0.16666666666666666 + 0.008333333333333333 \cdot \left(ky \cdot ky\right)\right)\right)}{\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.0200000000000000004

            1. Initial program 99.7%

              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
            2. Add Preprocessing
            3. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
              3. unpow2N/A

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

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

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

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

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

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

                if -0.0200000000000000004 < (sin.f64 ky) < 0.012

                1. Initial program 92.0%

                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                2. Add Preprocessing
                3. Step-by-step derivation
                  1. +-commutativeN/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                  3. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  if 0.012 < (sin.f64 ky)

                  1. Initial program 99.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 \color{blue}{\sin th} \]
                  4. Step-by-step derivation
                    1. sin-lowering-sin.f6462.5%

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

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

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

                Alternative 5: 62.7% accurate, 1.6× speedup?

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

                  1. Initial program 97.5%

                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                  2. Add Preprocessing
                  3. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  if 0.650000000000000022 < th < 7.3999999999999996e155

                  1. Initial program 88.6%

                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                  2. Add Preprocessing
                  3. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                    if 7.3999999999999996e155 < th

                    1. Initial program 93.3%

                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                    2. Add Preprocessing
                    3. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                      3. unpow2N/A

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

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

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

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

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

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

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

                    Alternative 6: 62.7% accurate, 1.7× speedup?

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

                      1. Initial program 97.5%

                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                      2. Add Preprocessing
                      3. Step-by-step derivation
                        1. +-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                        3. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      if 0.57999999999999996 < th < 6.99999999999999969e155

                      1. Initial program 88.6%

                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                      2. Add Preprocessing
                      3. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                        if 6.99999999999999969e155 < th

                        1. Initial program 93.3%

                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                        2. Add Preprocessing
                        3. Step-by-step derivation
                          1. +-commutativeN/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                          3. unpow2N/A

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

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

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

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

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

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

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

                        Alternative 7: 62.7% accurate, 1.7× speedup?

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

                          1. Initial program 97.5%

                            \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                          2. Add Preprocessing
                          3. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          if 0.69999999999999996 < th < 7.7999999999999996e155

                          1. Initial program 88.6%

                            \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                          2. Add Preprocessing
                          3. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                            if 7.7999999999999996e155 < th

                            1. Initial program 93.3%

                              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                            2. Add Preprocessing
                            3. Step-by-step derivation
                              1. +-commutativeN/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                              3. unpow2N/A

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

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

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

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

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

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

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

                            Alternative 8: 62.6% accurate, 1.7× speedup?

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

                              1. Initial program 97.5%

                                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                              2. Add Preprocessing
                              3. Step-by-step derivation
                                1. +-commutativeN/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                3. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              if 0.599999999999999978 < th < 5.39999999999999987e155

                              1. Initial program 88.6%

                                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                              2. Add Preprocessing
                              3. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                                if 5.39999999999999987e155 < th

                                1. Initial program 93.3%

                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                2. Add Preprocessing
                                3. Step-by-step derivation
                                  1. +-commutativeN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                  3. unpow2N/A

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

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

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

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

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

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

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

                                Alternative 9: 62.6% accurate, 1.7× speedup?

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

                                  1. Initial program 97.5%

                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                  2. Add Preprocessing
                                  3. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  if 0.57999999999999996 < th < 8.6000000000000005e155

                                  1. Initial program 88.6%

                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                  2. Add Preprocessing
                                  3. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    if 8.6000000000000005e155 < th

                                    1. Initial program 93.3%

                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                    2. Add Preprocessing
                                    3. Step-by-step derivation
                                      1. +-commutativeN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                      3. unpow2N/A

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

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

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

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

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

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

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

                                    Alternative 10: 62.7% accurate, 1.7× speedup?

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

                                      1. Initial program 97.5%

                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                      2. Add Preprocessing
                                      3. Step-by-step derivation
                                        1. +-commutativeN/A

                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                        3. unpow2N/A

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

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

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

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

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

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

                                        if 3.4e-4 < th < 6.8000000000000002e155

                                        1. Initial program 88.9%

                                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                        2. Add Preprocessing
                                        3. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          if 6.8000000000000002e155 < th

                                          1. Initial program 93.3%

                                            \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                          2. Add Preprocessing
                                          3. Step-by-step derivation
                                            1. +-commutativeN/A

                                              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                            3. unpow2N/A

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

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

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

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

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

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

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

                                          Alternative 11: 62.8% accurate, 1.7× speedup?

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

                                            1. Initial program 97.5%

                                              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                            2. Add Preprocessing
                                            3. Step-by-step derivation
                                              1. +-commutativeN/A

                                                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                              3. unpow2N/A

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

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

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

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

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

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

                                              if 4.6000000000000001e-4 < th < 7.4999999999999999e155

                                              1. Initial program 88.9%

                                                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                              2. Add Preprocessing
                                              3. Step-by-step derivation
                                                1. +-commutativeN/A

                                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                                3. unpow2N/A

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

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

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

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

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

                                                if 7.4999999999999999e155 < th

                                                1. Initial program 93.3%

                                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                2. Add Preprocessing
                                                3. Step-by-step derivation
                                                  1. +-commutativeN/A

                                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                                  3. unpow2N/A

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

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

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

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

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

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

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

                                                Alternative 12: 62.7% accurate, 1.7× speedup?

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

                                                  1. Initial program 97.5%

                                                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                  2. Add Preprocessing
                                                  3. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                    if 1.80000000000000011e-4 < th < 6.19999999999999978e155

                                                    1. Initial program 88.9%

                                                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                    2. Add Preprocessing
                                                    3. Step-by-step derivation
                                                      1. +-commutativeN/A

                                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                                      3. unpow2N/A

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

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

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

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

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

                                                      if 6.19999999999999978e155 < th

                                                      1. Initial program 93.3%

                                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                      2. Add Preprocessing
                                                      3. Step-by-step derivation
                                                        1. +-commutativeN/A

                                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                                        3. unpow2N/A

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

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

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

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

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

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

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

                                                      Alternative 13: 57.0% accurate, 1.7× speedup?

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

                                                        1. Initial program 94.2%

                                                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                        2. Add Preprocessing
                                                        3. Step-by-step derivation
                                                          1. +-commutativeN/A

                                                            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                                          3. unpow2N/A

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

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

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

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

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

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

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

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

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

                                                              if 9.9999999999999995e-8 < (sin.f64 kx)

                                                              1. Initial program 99.5%

                                                                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                              2. Add Preprocessing
                                                              3. Step-by-step derivation
                                                                1. clear-numN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                            Alternative 14: 64.2% accurate, 1.7× speedup?

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

                                                              1. Initial program 94.5%

                                                                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                              2. Add Preprocessing
                                                              3. Step-by-step derivation
                                                                1. +-commutativeN/A

                                                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                                                3. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                              if 2.15e21 < ky

                                                              1. Initial program 99.7%

                                                                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                              2. Add Preprocessing
                                                              3. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                              Alternative 15: 57.0% accurate, 1.7× speedup?

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

                                                                1. Initial program 94.2%

                                                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                                2. Add Preprocessing
                                                                3. Step-by-step derivation
                                                                  1. +-commutativeN/A

                                                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                                                  3. unpow2N/A

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

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

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

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

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

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

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

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

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

                                                                      if 9.9999999999999995e-8 < (sin.f64 kx)

                                                                      1. Initial program 99.5%

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

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

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

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

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

                                                                    Alternative 16: 54.8% accurate, 2.3× speedup?

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

                                                                      1. Initial program 94.2%

                                                                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                                      2. Add Preprocessing
                                                                      3. Step-by-step derivation
                                                                        1. +-commutativeN/A

                                                                          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                                                        3. unpow2N/A

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

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

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

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

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

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

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

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

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

                                                                            if 9.9999999999999995e-8 < (sin.f64 kx)

                                                                            1. Initial program 99.5%

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

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

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

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

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

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

                                                                          Alternative 17: 33.6% accurate, 2.3× speedup?

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

                                                                            1. Initial program 93.7%

                                                                              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                                            2. Add Preprocessing
                                                                            3. Step-by-step derivation
                                                                              1. +-commutativeN/A

                                                                                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                                                              3. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                              if 4.99999999999999989e-138 < (sin.f64 ky)

                                                                              1. Initial program 99.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 \color{blue}{\sin th} \]
                                                                              4. Step-by-step derivation
                                                                                1. sin-lowering-sin.f6456.9%

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

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

                                                                            Alternative 18: 33.1% accurate, 3.4× speedup?

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

                                                                              1. Initial program 94.0%

                                                                                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                                              2. Add Preprocessing
                                                                              3. Step-by-step derivation
                                                                                1. +-commutativeN/A

                                                                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                                                                3. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                              if 1.1499999999999999e-54 < ky

                                                                              1. Initial program 99.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 \color{blue}{\sin th} \]
                                                                              4. Step-by-step derivation
                                                                                1. sin-lowering-sin.f6434.1%

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

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

                                                                            Alternative 19: 33.1% accurate, 3.4× speedup?

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

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

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

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

                                                                              if 1.25000000000000004e-54 < ky

                                                                              1. Initial program 99.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 \color{blue}{\sin th} \]
                                                                              4. Step-by-step derivation
                                                                                1. sin-lowering-sin.f6434.1%

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

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

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

                                                                            Alternative 20: 26.6% accurate, 6.4× speedup?

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

                                                                              1. Initial program 93.2%

                                                                                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                                              2. Add Preprocessing
                                                                              3. Step-by-step derivation
                                                                                1. +-commutativeN/A

                                                                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                                                                3. unpow2N/A

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

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

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

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

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

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

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

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

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

                                                                                if 2.6e-137 < ky

                                                                                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 0

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

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

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

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

                                                                              Alternative 21: 26.6% accurate, 6.4× speedup?

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

                                                                                1. Initial program 93.2%

                                                                                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                                                                                2. Add Preprocessing
                                                                                3. Step-by-step derivation
                                                                                  1. +-commutativeN/A

                                                                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{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 ky \cdot \sin ky + {\sin kx}^{2}}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
                                                                                  3. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                  if 3.05000000000000003e-137 < ky

                                                                                  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 0

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

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

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

                                                                                Alternative 22: 25.0% accurate, 6.7× speedup?

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

                                                                                  1. Initial program 94.6%

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

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

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

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

                                                                                  if 1.1e22 < kx

                                                                                  1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

                                                                                      \[\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) \]
                                                                                  8. Simplified5.1%

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

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

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

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

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

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

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

                                                                                      \[\leadsto \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(th, \mathsf{*.f64}\left(th, \color{blue}{th}\right)\right)\right) \]
                                                                                  11. Simplified16.7%

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

                                                                                Alternative 23: 14.9% accurate, 59.0× speedup?

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

                                                                                  1. Initial program 94.6%

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

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

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

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

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

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

                                                                                    if 7.6e21 < kx

                                                                                    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

                                                                                        \[\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) \]
                                                                                    8. Simplified5.1%

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

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

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

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

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

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

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

                                                                                        \[\leadsto \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(th, \mathsf{*.f64}\left(th, \color{blue}{th}\right)\right)\right) \]
                                                                                    11. Simplified16.7%

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

                                                                                  Alternative 24: 13.0% accurate, 709.0× speedup?

                                                                                  \[\begin{array}{l} \\ th \end{array} \]
                                                                                  (FPCore (kx ky th) :precision binary64 th)
                                                                                  double code(double kx, double ky, double th) {
                                                                                  	return th;
                                                                                  }
                                                                                  
                                                                                  real(8) function code(kx, ky, th)
                                                                                      real(8), intent (in) :: kx
                                                                                      real(8), intent (in) :: ky
                                                                                      real(8), intent (in) :: th
                                                                                      code = th
                                                                                  end function
                                                                                  
                                                                                  public static double code(double kx, double ky, double th) {
                                                                                  	return th;
                                                                                  }
                                                                                  
                                                                                  def code(kx, ky, th):
                                                                                  	return th
                                                                                  
                                                                                  function code(kx, ky, th)
                                                                                  	return th
                                                                                  end
                                                                                  
                                                                                  function tmp = code(kx, ky, th)
                                                                                  	tmp = th;
                                                                                  end
                                                                                  
                                                                                  code[kx_, ky_, th_] := th
                                                                                  
                                                                                  \begin{array}{l}
                                                                                  
                                                                                  \\
                                                                                  th
                                                                                  \end{array}
                                                                                  
                                                                                  Derivation
                                                                                  1. Initial program 95.8%

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

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

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

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

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

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

                                                                                    Reproduce

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