Toniolo and Linder, Equation (3b), real

Percentage Accurate: 93.8% → 99.7%
Time: 27.5s
Alternatives: 19
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 19 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: 93.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 77.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_1 := ky \cdot \left(1 + \left(ky \cdot ky\right) \cdot -0.16666666666666666\right)\\
\mathbf{if}\;\sin ky \leq -0.02:\\
\;\;\;\;0 - \sin th\\

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

\mathbf{elif}\;\sin ky \leq 0.385:\\
\;\;\;\;\sin th\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 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. Step-by-step derivation
      1. associate-*l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \sin th} \]
    12. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\sin th\right) \]
      2. neg-sub0N/A

        \[\leadsto 0 - \color{blue}{\sin th} \]
      3. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\sin th}\right) \]
      4. sin-lowering-sin.f6461.3%

        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(th\right)\right) \]
    13. Simplified61.3%

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

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

    1. Initial program 86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.029999999999999999 < (sin.f64 ky) < 0.38500000000000001

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.38500000000000001 < (sin.f64 ky)

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 3: 79.0% accurate, 1.1× speedup?

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

      1. Initial program 85.2%

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

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

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

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

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

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

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

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

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

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

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

        if 5.0000000000000002e-14 < (pow.f64 (sin.f64 kx) #s(literal 2 binary64))

        1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{pow.f64}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot kx\right)\right), \frac{1}{2}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
          7. cancel-sign-sub-invN/A

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{pow.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \cos \left(2 \cdot kx\right)\right)\right), \frac{1}{2}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
          11. count-2N/A

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{pow.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{cos.f64}\left(\left(kx + kx\right)\right)\right)\right), \frac{1}{2}\right)\right), \mathsf{sin.f64}\left(th\right)\right) \]
          13. count-2N/A

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

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

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

          \[\leadsto \frac{\sin ky}{\color{blue}{{\left(0.5 + -0.5 \cdot \cos \left(kx \cdot 2\right)\right)}^{0.5}}} \cdot \sin th \]
      8. Recombined 2 regimes into one program.
      9. Final simplification81.0%

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

      Alternative 4: 79.1% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{-1 \cdot \sin th} \]
        12. Step-by-step derivation
          1. mul-1-negN/A

            \[\leadsto \mathsf{neg}\left(\sin th\right) \]
          2. neg-sub0N/A

            \[\leadsto 0 - \color{blue}{\sin th} \]
          3. --lowering--.f64N/A

            \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\sin th}\right) \]
          4. sin-lowering-sin.f6461.3%

            \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(th\right)\right) \]
        13. Simplified61.3%

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

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

        1. Initial program 86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if 0.029999999999999999 < (sin.f64 ky)

        1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 5: 79.1% accurate, 1.3× speedup?

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

        1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{-1 \cdot \sin th} \]
        12. Step-by-step derivation
          1. mul-1-negN/A

            \[\leadsto \mathsf{neg}\left(\sin th\right) \]
          2. neg-sub0N/A

            \[\leadsto 0 - \color{blue}{\sin th} \]
          3. --lowering--.f64N/A

            \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\sin th}\right) \]
          4. sin-lowering-sin.f6461.3%

            \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(th\right)\right) \]
        13. Simplified61.3%

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

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

        1. Initial program 86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if 0.029999999999999999 < (sin.f64 ky)

        1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 6: 78.8% accurate, 1.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq -0.02:\\ \;\;\;\;0 - \sin th\\ \mathbf{elif}\;\sin ky \leq 10^{-12}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky \cdot \left(1 + \left(ky \cdot ky\right) \cdot -0.16666666666666666\right), \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
      (FPCore (kx ky th)
       :precision binary64
       (if (<= (sin ky) -0.02)
         (- 0.0 (sin th))
         (if (<= (sin ky) 1e-12)
           (*
            ky
            (/
             (sin th)
             (hypot (* ky (+ 1.0 (* (* ky ky) -0.16666666666666666))) (sin kx))))
           (sin th))))
      double code(double kx, double ky, double th) {
      	double tmp;
      	if (sin(ky) <= -0.02) {
      		tmp = 0.0 - sin(th);
      	} else if (sin(ky) <= 1e-12) {
      		tmp = ky * (sin(th) / hypot((ky * (1.0 + ((ky * ky) * -0.16666666666666666))), 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 = 0.0 - Math.sin(th);
      	} else if (Math.sin(ky) <= 1e-12) {
      		tmp = ky * (Math.sin(th) / Math.hypot((ky * (1.0 + ((ky * ky) * -0.16666666666666666))), Math.sin(kx)));
      	} else {
      		tmp = Math.sin(th);
      	}
      	return tmp;
      }
      
      def code(kx, ky, th):
      	tmp = 0
      	if math.sin(ky) <= -0.02:
      		tmp = 0.0 - math.sin(th)
      	elif math.sin(ky) <= 1e-12:
      		tmp = ky * (math.sin(th) / math.hypot((ky * (1.0 + ((ky * ky) * -0.16666666666666666))), 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(0.0 - sin(th));
      	elseif (sin(ky) <= 1e-12)
      		tmp = Float64(ky * Float64(sin(th) / hypot(Float64(ky * Float64(1.0 + Float64(Float64(ky * ky) * -0.16666666666666666))), 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 = 0.0 - sin(th);
      	elseif (sin(ky) <= 1e-12)
      		tmp = ky * (sin(th) / hypot((ky * (1.0 + ((ky * ky) * -0.16666666666666666))), sin(kx)));
      	else
      		tmp = sin(th);
      	end
      	tmp_2 = tmp;
      end
      
      code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], N[(0.0 - N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-12], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[(ky * N[(1.0 + N[(N[(ky * ky), $MachinePrecision] * -0.16666666666666666), $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:\\
      \;\;\;\;0 - \sin th\\
      
      \mathbf{elif}\;\sin ky \leq 10^{-12}:\\
      \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky \cdot \left(1 + \left(ky \cdot ky\right) \cdot -0.16666666666666666\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. Step-by-step derivation
          1. associate-*l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{-1 \cdot \sin th} \]
        12. Step-by-step derivation
          1. mul-1-negN/A

            \[\leadsto \mathsf{neg}\left(\sin th\right) \]
          2. neg-sub0N/A

            \[\leadsto 0 - \color{blue}{\sin th} \]
          3. --lowering--.f64N/A

            \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\sin th}\right) \]
          4. sin-lowering-sin.f6461.3%

            \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(th\right)\right) \]
        13. Simplified61.3%

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

        if -0.0200000000000000004 < (sin.f64 ky) < 9.9999999999999998e-13

        1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if 9.9999999999999998e-13 < (sin.f64 ky)

          1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 7: 54.7% accurate, 1.4× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq -0.02:\\ \;\;\;\;0 - \sin th\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-50}:\\ \;\;\;\;\frac{\sin th}{\frac{\sin kx}{\sin ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
        (FPCore (kx ky th)
         :precision binary64
         (if (<= (sin ky) -0.02)
           (- 0.0 (sin th))
           (if (<= (sin ky) 2e-50) (/ (sin th) (/ (sin kx) (sin ky))) (sin th))))
        double code(double kx, double ky, double th) {
        	double tmp;
        	if (sin(ky) <= -0.02) {
        		tmp = 0.0 - sin(th);
        	} else if (sin(ky) <= 2e-50) {
        		tmp = sin(th) / (sin(kx) / sin(ky));
        	} else {
        		tmp = sin(th);
        	}
        	return tmp;
        }
        
        real(8) function code(kx, ky, th)
            real(8), intent (in) :: kx
            real(8), intent (in) :: ky
            real(8), intent (in) :: th
            real(8) :: tmp
            if (sin(ky) <= (-0.02d0)) then
                tmp = 0.0d0 - sin(th)
            else if (sin(ky) <= 2d-50) then
                tmp = sin(th) / (sin(kx) / sin(ky))
            else
                tmp = sin(th)
            end if
            code = tmp
        end function
        
        public static double code(double kx, double ky, double th) {
        	double tmp;
        	if (Math.sin(ky) <= -0.02) {
        		tmp = 0.0 - Math.sin(th);
        	} else if (Math.sin(ky) <= 2e-50) {
        		tmp = Math.sin(th) / (Math.sin(kx) / Math.sin(ky));
        	} else {
        		tmp = Math.sin(th);
        	}
        	return tmp;
        }
        
        def code(kx, ky, th):
        	tmp = 0
        	if math.sin(ky) <= -0.02:
        		tmp = 0.0 - math.sin(th)
        	elif math.sin(ky) <= 2e-50:
        		tmp = math.sin(th) / (math.sin(kx) / math.sin(ky))
        	else:
        		tmp = math.sin(th)
        	return tmp
        
        function code(kx, ky, th)
        	tmp = 0.0
        	if (sin(ky) <= -0.02)
        		tmp = Float64(0.0 - sin(th));
        	elseif (sin(ky) <= 2e-50)
        		tmp = Float64(sin(th) / Float64(sin(kx) / sin(ky)));
        	else
        		tmp = sin(th);
        	end
        	return tmp
        end
        
        function tmp_2 = code(kx, ky, th)
        	tmp = 0.0;
        	if (sin(ky) <= -0.02)
        		tmp = 0.0 - sin(th);
        	elseif (sin(ky) <= 2e-50)
        		tmp = sin(th) / (sin(kx) / sin(ky));
        	else
        		tmp = sin(th);
        	end
        	tmp_2 = tmp;
        end
        
        code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.02], N[(0.0 - N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-50], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\sin ky \leq -0.02:\\
        \;\;\;\;0 - \sin th\\
        
        \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-50}:\\
        \;\;\;\;\frac{\sin th}{\frac{\sin kx}{\sin ky}}\\
        
        \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. Step-by-step derivation
            1. associate-*l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{-1 \cdot \sin th} \]
          12. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(\sin th\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{\sin th} \]
            3. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\sin th}\right) \]
            4. sin-lowering-sin.f6461.3%

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(th\right)\right) \]
          13. Simplified61.3%

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

          if -0.0200000000000000004 < (sin.f64 ky) < 2.00000000000000002e-50

          1. Initial program 85.8%

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

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

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

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

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

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

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

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

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

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

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

          if 2.00000000000000002e-50 < (sin.f64 ky)

          1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 8: 54.7% accurate, 1.4× speedup?

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

          1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{-1 \cdot \sin th} \]
          12. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(\sin th\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{\sin th} \]
            3. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\sin th}\right) \]
            4. sin-lowering-sin.f6461.3%

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(th\right)\right) \]
          13. Simplified61.3%

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

          if -0.0200000000000000004 < (sin.f64 ky) < 2.00000000000000002e-50

          1. Initial program 85.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if 2.00000000000000002e-50 < (sin.f64 ky)

          1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 9: 99.6% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 10: 54.7% accurate, 1.7× speedup?

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

          1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{-1 \cdot \sin th} \]
          12. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(\sin th\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{\sin th} \]
            3. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\sin th}\right) \]
            4. sin-lowering-sin.f6461.3%

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(th\right)\right) \]
          13. Simplified61.3%

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

          if -0.0200000000000000004 < (sin.f64 ky) < 2.00000000000000002e-50

          1. Initial program 85.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if 2.00000000000000002e-50 < (sin.f64 ky)

          1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 11: 54.7% accurate, 1.7× speedup?

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

          1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{-1 \cdot \sin th} \]
          12. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(\sin th\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{\sin th} \]
            3. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\sin th}\right) \]
            4. sin-lowering-sin.f6461.3%

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(th\right)\right) \]
          13. Simplified61.3%

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

          if -0.0200000000000000004 < (sin.f64 ky) < 2.00000000000000002e-50

          1. Initial program 85.8%

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

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

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

          if 2.00000000000000002e-50 < (sin.f64 ky)

          1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 12: 47.2% accurate, 1.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq -0.02:\\ \;\;\;\;0 - \sin th\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-74}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
        (FPCore (kx ky th)
         :precision binary64
         (if (<= (sin ky) -0.02)
           (- 0.0 (sin th))
           (if (<= (sin ky) 2e-74) (* (sin ky) (/ (sin th) kx)) (sin th))))
        double code(double kx, double ky, double th) {
        	double tmp;
        	if (sin(ky) <= -0.02) {
        		tmp = 0.0 - sin(th);
        	} else if (sin(ky) <= 2e-74) {
        		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) <= (-0.02d0)) then
                tmp = 0.0d0 - sin(th)
            else if (sin(ky) <= 2d-74) 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) <= -0.02) {
        		tmp = 0.0 - Math.sin(th);
        	} else if (Math.sin(ky) <= 2e-74) {
        		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) <= -0.02:
        		tmp = 0.0 - math.sin(th)
        	elif math.sin(ky) <= 2e-74:
        		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) <= -0.02)
        		tmp = Float64(0.0 - sin(th));
        	elseif (sin(ky) <= 2e-74)
        		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) <= -0.02)
        		tmp = 0.0 - sin(th);
        	elseif (sin(ky) <= 2e-74)
        		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], -0.02], N[(0.0 - N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-74], 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 -0.02:\\
        \;\;\;\;0 - \sin th\\
        
        \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-74}:\\
        \;\;\;\;\sin ky \cdot \frac{\sin th}{kx}\\
        
        \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. Step-by-step derivation
            1. associate-*l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{-1 \cdot \sin th} \]
          12. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(\sin th\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{\sin th} \]
            3. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\sin th}\right) \]
            4. sin-lowering-sin.f6461.3%

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(th\right)\right) \]
          13. Simplified61.3%

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

          if -0.0200000000000000004 < (sin.f64 ky) < 1.99999999999999992e-74

          1. Initial program 85.3%

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

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

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

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

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

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

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

          if 1.99999999999999992e-74 < (sin.f64 ky)

          1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 13: 46.3% accurate, 2.3× speedup?

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

          1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{-1 \cdot \sin th} \]
          12. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(\sin th\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{\sin th} \]
            3. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\sin th}\right) \]
            4. sin-lowering-sin.f6461.3%

              \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(th\right)\right) \]
          13. Simplified61.3%

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

          if -0.0200000000000000004 < (sin.f64 ky) < 1.99999999999999992e-74

          1. Initial program 85.3%

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

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

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

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

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

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

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

            if 1.99999999999999992e-74 < (sin.f64 ky)

            1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\sin th} \]
            6. Step-by-step derivation
              1. sin-lowering-sin.f6459.7%

                \[\leadsto \mathsf{sin.f64}\left(th\right) \]
            7. Simplified59.7%

              \[\leadsto \color{blue}{\sin th} \]
          5. Recombined 3 regimes into one program.
          6. Final simplification43.6%

            \[\leadsto \begin{array}{l} \mathbf{if}\;\sin ky \leq -0.02:\\ \;\;\;\;0 - \sin th\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-74}:\\ \;\;\;\;th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
          7. Add Preprocessing

          Alternative 14: 26.8% accurate, 6.2× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 6.6 \cdot 10^{-59}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;kx \leq 2.35 \cdot 10^{-7}:\\ \;\;\;\;0 - \sin th\\ \mathbf{else}:\\ \;\;\;\;ky \cdot \frac{th}{\sin kx}\\ \end{array} \end{array} \]
          (FPCore (kx ky th)
           :precision binary64
           (if (<= kx 6.6e-59)
             (sin th)
             (if (<= kx 2.35e-7) (- 0.0 (sin th)) (* ky (/ th (sin kx))))))
          double code(double kx, double ky, double th) {
          	double tmp;
          	if (kx <= 6.6e-59) {
          		tmp = sin(th);
          	} else if (kx <= 2.35e-7) {
          		tmp = 0.0 - sin(th);
          	} else {
          		tmp = ky * (th / sin(kx));
          	}
          	return tmp;
          }
          
          real(8) function code(kx, ky, th)
              real(8), intent (in) :: kx
              real(8), intent (in) :: ky
              real(8), intent (in) :: th
              real(8) :: tmp
              if (kx <= 6.6d-59) then
                  tmp = sin(th)
              else if (kx <= 2.35d-7) then
                  tmp = 0.0d0 - sin(th)
              else
                  tmp = ky * (th / sin(kx))
              end if
              code = tmp
          end function
          
          public static double code(double kx, double ky, double th) {
          	double tmp;
          	if (kx <= 6.6e-59) {
          		tmp = Math.sin(th);
          	} else if (kx <= 2.35e-7) {
          		tmp = 0.0 - Math.sin(th);
          	} else {
          		tmp = ky * (th / Math.sin(kx));
          	}
          	return tmp;
          }
          
          def code(kx, ky, th):
          	tmp = 0
          	if kx <= 6.6e-59:
          		tmp = math.sin(th)
          	elif kx <= 2.35e-7:
          		tmp = 0.0 - math.sin(th)
          	else:
          		tmp = ky * (th / math.sin(kx))
          	return tmp
          
          function code(kx, ky, th)
          	tmp = 0.0
          	if (kx <= 6.6e-59)
          		tmp = sin(th);
          	elseif (kx <= 2.35e-7)
          		tmp = Float64(0.0 - sin(th));
          	else
          		tmp = Float64(ky * Float64(th / sin(kx)));
          	end
          	return tmp
          end
          
          function tmp_2 = code(kx, ky, th)
          	tmp = 0.0;
          	if (kx <= 6.6e-59)
          		tmp = sin(th);
          	elseif (kx <= 2.35e-7)
          		tmp = 0.0 - sin(th);
          	else
          		tmp = ky * (th / sin(kx));
          	end
          	tmp_2 = tmp;
          end
          
          code[kx_, ky_, th_] := If[LessEqual[kx, 6.6e-59], N[Sin[th], $MachinePrecision], If[LessEqual[kx, 2.35e-7], N[(0.0 - N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(ky * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;kx \leq 6.6 \cdot 10^{-59}:\\
          \;\;\;\;\sin th\\
          
          \mathbf{elif}\;kx \leq 2.35 \cdot 10^{-7}:\\
          \;\;\;\;0 - \sin th\\
          
          \mathbf{else}:\\
          \;\;\;\;ky \cdot \frac{th}{\sin kx}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if kx < 6.59999999999999964e-59

            1. Initial program 89.9%

              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
            2. Step-by-step derivation
              1. associate-*l/N/A

                \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
              2. associate-/l*N/A

                \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
              3. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\sin ky, \color{blue}{\left(\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right)}\right) \]
              4. sin-lowering-sin.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\frac{\color{blue}{\sin th}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right) \]
              5. /-lowering-/.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
              6. sin-lowering-sin.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
              7. +-commutativeN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
              8. unpow2N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
              9. unpow2N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
              10. hypot-defineN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
              11. hypot-lowering-hypot.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
              12. sin-lowering-sin.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
              13. sin-lowering-sin.f6499.7%

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
            3. Simplified99.7%

              \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
            4. Add Preprocessing
            5. Taylor expanded in kx around 0

              \[\leadsto \color{blue}{\sin th} \]
            6. Step-by-step derivation
              1. sin-lowering-sin.f6429.8%

                \[\leadsto \mathsf{sin.f64}\left(th\right) \]
            7. Simplified29.8%

              \[\leadsto \color{blue}{\sin th} \]

            if 6.59999999999999964e-59 < kx < 2.35e-7

            1. Initial program 99.9%

              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
            2. Step-by-step derivation
              1. associate-*l/N/A

                \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
              2. associate-/l*N/A

                \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
              3. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\sin ky, \color{blue}{\left(\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right)}\right) \]
              4. sin-lowering-sin.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\frac{\color{blue}{\sin th}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right) \]
              5. /-lowering-/.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
              6. sin-lowering-sin.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
              7. +-commutativeN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
              8. unpow2N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
              9. unpow2N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
              10. hypot-defineN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
              11. hypot-lowering-hypot.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
              12. sin-lowering-sin.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
              13. sin-lowering-sin.f6499.3%

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
            3. Simplified99.3%

              \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
            4. Add Preprocessing
            5. Taylor expanded in ky around 0

              \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\color{blue}{\left(ky \cdot \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)\right)}, \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
            6. Step-by-step derivation
              1. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)\right), \mathsf{sin.f64}\left(\color{blue}{kx}\right)\right)\right)\right) \]
              2. +-lowering-+.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot {ky}^{2}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
              3. *-commutativeN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \left({ky}^{2} \cdot \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
              4. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({ky}^{2}\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
              5. unpow2N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(ky \cdot ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
              6. *-lowering-*.f6434.3%

                \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
            7. Simplified34.3%

              \[\leadsto \sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\color{blue}{ky \cdot \left(1 + \left(ky \cdot ky\right) \cdot -0.16666666666666666\right)}, \sin kx\right)} \]
            8. Taylor expanded in ky around 0

              \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(ky \cdot \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)\right)}, \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
            9. Step-by-step derivation
              1. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)\right), \mathsf{/.f64}\left(\color{blue}{\mathsf{sin.f64}\left(th\right)}, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
              2. +-lowering-+.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot {ky}^{2}\right)\right)\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
              3. *-commutativeN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \left({ky}^{2} \cdot \frac{-1}{6}\right)\right)\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
              4. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({ky}^{2}\right), \frac{-1}{6}\right)\right)\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
              5. unpow2N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(ky \cdot ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
              6. *-lowering-*.f6449.8%

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
            10. Simplified49.8%

              \[\leadsto \color{blue}{\left(ky \cdot \left(1 + \left(ky \cdot ky\right) \cdot -0.16666666666666666\right)\right)} \cdot \frac{\sin th}{\mathsf{hypot}\left(ky \cdot \left(1 + \left(ky \cdot ky\right) \cdot -0.16666666666666666\right), \sin kx\right)} \]
            11. Taylor expanded in ky around inf

              \[\leadsto \color{blue}{-1 \cdot \sin th} \]
            12. Step-by-step derivation
              1. mul-1-negN/A

                \[\leadsto \mathsf{neg}\left(\sin th\right) \]
              2. neg-sub0N/A

                \[\leadsto 0 - \color{blue}{\sin th} \]
              3. --lowering--.f64N/A

                \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\sin th}\right) \]
              4. sin-lowering-sin.f6445.0%

                \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(th\right)\right) \]
            13. Simplified45.0%

              \[\leadsto \color{blue}{0 - \sin th} \]

            if 2.35e-7 < kx

            1. Initial program 99.3%

              \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
            2. Add Preprocessing
            3. Taylor expanded in th around 0

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{sin.f64}\left(kx\right), 2\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), \color{blue}{th}\right) \]
            4. Step-by-step derivation
              1. Simplified44.5%

                \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \color{blue}{th} \]
              2. Taylor expanded in ky around 0

                \[\leadsto \color{blue}{\frac{ky \cdot th}{\sin kx}} \]
              3. Step-by-step derivation
                1. associate-/l*N/A

                  \[\leadsto ky \cdot \color{blue}{\frac{th}{\sin kx}} \]
                2. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(ky, \color{blue}{\left(\frac{th}{\sin kx}\right)}\right) \]
                3. /-lowering-/.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(ky, \mathsf{/.f64}\left(th, \color{blue}{\sin kx}\right)\right) \]
                4. sin-lowering-sin.f6417.5%

                  \[\leadsto \mathsf{*.f64}\left(ky, \mathsf{/.f64}\left(th, \mathsf{sin.f64}\left(kx\right)\right)\right) \]
              4. Simplified17.5%

                \[\leadsto \color{blue}{ky \cdot \frac{th}{\sin kx}} \]
            5. Recombined 3 regimes into one program.
            6. Add Preprocessing

            Alternative 15: 23.6% accurate, 6.3× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 1.46 \cdot 10^{-233}:\\ \;\;\;\;\frac{th}{\frac{kx}{ky}}\\ \mathbf{elif}\;ky \leq 3.65 \cdot 10^{+49}:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;0 - \sin th\\ \end{array} \end{array} \]
            (FPCore (kx ky th)
             :precision binary64
             (if (<= ky 1.46e-233)
               (/ th (/ kx ky))
               (if (<= ky 3.65e+49) (sin th) (- 0.0 (sin th)))))
            double code(double kx, double ky, double th) {
            	double tmp;
            	if (ky <= 1.46e-233) {
            		tmp = th / (kx / ky);
            	} else if (ky <= 3.65e+49) {
            		tmp = sin(th);
            	} else {
            		tmp = 0.0 - 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.46d-233) then
                    tmp = th / (kx / ky)
                else if (ky <= 3.65d+49) then
                    tmp = sin(th)
                else
                    tmp = 0.0d0 - sin(th)
                end if
                code = tmp
            end function
            
            public static double code(double kx, double ky, double th) {
            	double tmp;
            	if (ky <= 1.46e-233) {
            		tmp = th / (kx / ky);
            	} else if (ky <= 3.65e+49) {
            		tmp = Math.sin(th);
            	} else {
            		tmp = 0.0 - Math.sin(th);
            	}
            	return tmp;
            }
            
            def code(kx, ky, th):
            	tmp = 0
            	if ky <= 1.46e-233:
            		tmp = th / (kx / ky)
            	elif ky <= 3.65e+49:
            		tmp = math.sin(th)
            	else:
            		tmp = 0.0 - math.sin(th)
            	return tmp
            
            function code(kx, ky, th)
            	tmp = 0.0
            	if (ky <= 1.46e-233)
            		tmp = Float64(th / Float64(kx / ky));
            	elseif (ky <= 3.65e+49)
            		tmp = sin(th);
            	else
            		tmp = Float64(0.0 - sin(th));
            	end
            	return tmp
            end
            
            function tmp_2 = code(kx, ky, th)
            	tmp = 0.0;
            	if (ky <= 1.46e-233)
            		tmp = th / (kx / ky);
            	elseif (ky <= 3.65e+49)
            		tmp = sin(th);
            	else
            		tmp = 0.0 - sin(th);
            	end
            	tmp_2 = tmp;
            end
            
            code[kx_, ky_, th_] := If[LessEqual[ky, 1.46e-233], N[(th / N[(kx / ky), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 3.65e+49], N[Sin[th], $MachinePrecision], N[(0.0 - N[Sin[th], $MachinePrecision]), $MachinePrecision]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;ky \leq 1.46 \cdot 10^{-233}:\\
            \;\;\;\;\frac{th}{\frac{kx}{ky}}\\
            
            \mathbf{elif}\;ky \leq 3.65 \cdot 10^{+49}:\\
            \;\;\;\;\sin th\\
            
            \mathbf{else}:\\
            \;\;\;\;0 - \sin th\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if ky < 1.46000000000000011e-233

              1. Initial program 91.9%

                \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
              2. Add Preprocessing
              3. Taylor expanded in th around 0

                \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{sin.f64}\left(kx\right), 2\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), \color{blue}{th}\right) \]
              4. Step-by-step derivation
                1. Simplified45.7%

                  \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \color{blue}{th} \]
                2. Taylor expanded in kx around 0

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\color{blue}{\left({kx}^{2}\right)}, \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), th\right) \]
                3. Step-by-step derivation
                  1. unpow2N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(kx \cdot kx\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), th\right) \]
                  2. *-lowering-*.f6431.2%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(kx, kx\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), th\right) \]
                4. Simplified31.2%

                  \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{kx \cdot kx} + {\sin ky}^{2}}} \cdot th \]
                5. Taylor expanded in ky around 0

                  \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{ky}{kx}\right)}, th\right) \]
                6. Step-by-step derivation
                  1. /-lowering-/.f6413.4%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(ky, kx\right), th\right) \]
                7. Simplified13.4%

                  \[\leadsto \color{blue}{\frac{ky}{kx}} \cdot th \]
                8. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto th \cdot \color{blue}{\frac{ky}{kx}} \]
                  2. clear-numN/A

                    \[\leadsto th \cdot \frac{1}{\color{blue}{\frac{kx}{ky}}} \]
                  3. un-div-invN/A

                    \[\leadsto \frac{th}{\color{blue}{\frac{kx}{ky}}} \]
                  4. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(th, \color{blue}{\left(\frac{kx}{ky}\right)}\right) \]
                  5. /-lowering-/.f6413.5%

                    \[\leadsto \mathsf{/.f64}\left(th, \mathsf{/.f64}\left(kx, \color{blue}{ky}\right)\right) \]
                9. Applied egg-rr13.5%

                  \[\leadsto \color{blue}{\frac{th}{\frac{kx}{ky}}} \]

                if 1.46000000000000011e-233 < ky < 3.65000000000000007e49

                1. Initial program 90.2%

                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                2. Step-by-step derivation
                  1. associate-*l/N/A

                    \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                  2. associate-/l*N/A

                    \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                  3. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\sin ky, \color{blue}{\left(\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right)}\right) \]
                  4. sin-lowering-sin.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\frac{\color{blue}{\sin th}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right) \]
                  5. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                  6. sin-lowering-sin.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                  7. +-commutativeN/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                  8. unpow2N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                  9. unpow2N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                  10. hypot-defineN/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                  11. hypot-lowering-hypot.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                  12. sin-lowering-sin.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                  13. sin-lowering-sin.f6499.5%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                3. Simplified99.5%

                  \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
                4. Add Preprocessing
                5. Taylor expanded in kx around 0

                  \[\leadsto \color{blue}{\sin th} \]
                6. Step-by-step derivation
                  1. sin-lowering-sin.f6433.4%

                    \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                7. Simplified33.4%

                  \[\leadsto \color{blue}{\sin th} \]

                if 3.65000000000000007e49 < ky

                1. Initial program 99.7%

                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                2. Step-by-step derivation
                  1. associate-*l/N/A

                    \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                  2. associate-/l*N/A

                    \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                  3. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\sin ky, \color{blue}{\left(\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right)}\right) \]
                  4. sin-lowering-sin.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\frac{\color{blue}{\sin th}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right) \]
                  5. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                  6. sin-lowering-sin.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                  7. +-commutativeN/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                  8. unpow2N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                  9. unpow2N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                  10. hypot-defineN/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                  11. hypot-lowering-hypot.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                  12. sin-lowering-sin.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                  13. sin-lowering-sin.f6499.5%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                3. Simplified99.5%

                  \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
                4. Add Preprocessing
                5. Taylor expanded in ky around 0

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\color{blue}{\left(ky \cdot \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)\right)}, \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                6. Step-by-step derivation
                  1. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)\right), \mathsf{sin.f64}\left(\color{blue}{kx}\right)\right)\right)\right) \]
                  2. +-lowering-+.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot {ky}^{2}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                  3. *-commutativeN/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \left({ky}^{2} \cdot \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                  4. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({ky}^{2}\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                  5. unpow2N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(ky \cdot ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                  6. *-lowering-*.f644.7%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                7. Simplified4.7%

                  \[\leadsto \sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\color{blue}{ky \cdot \left(1 + \left(ky \cdot ky\right) \cdot -0.16666666666666666\right)}, \sin kx\right)} \]
                8. Taylor expanded in ky around 0

                  \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(ky \cdot \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)\right)}, \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                9. Step-by-step derivation
                  1. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, \left(1 + \frac{-1}{6} \cdot {ky}^{2}\right)\right), \mathsf{/.f64}\left(\color{blue}{\mathsf{sin.f64}\left(th\right)}, \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                  2. +-lowering-+.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot {ky}^{2}\right)\right)\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                  3. *-commutativeN/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \left({ky}^{2} \cdot \frac{-1}{6}\right)\right)\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                  4. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({ky}^{2}\right), \frac{-1}{6}\right)\right)\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                  5. unpow2N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(ky \cdot ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                  6. *-lowering-*.f646.3%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{*.f64}\left(ky, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(ky, ky\right), \frac{-1}{6}\right)\right)\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                10. Simplified6.3%

                  \[\leadsto \color{blue}{\left(ky \cdot \left(1 + \left(ky \cdot ky\right) \cdot -0.16666666666666666\right)\right)} \cdot \frac{\sin th}{\mathsf{hypot}\left(ky \cdot \left(1 + \left(ky \cdot ky\right) \cdot -0.16666666666666666\right), \sin kx\right)} \]
                11. Taylor expanded in ky around inf

                  \[\leadsto \color{blue}{-1 \cdot \sin th} \]
                12. Step-by-step derivation
                  1. mul-1-negN/A

                    \[\leadsto \mathsf{neg}\left(\sin th\right) \]
                  2. neg-sub0N/A

                    \[\leadsto 0 - \color{blue}{\sin th} \]
                  3. --lowering--.f64N/A

                    \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\sin th}\right) \]
                  4. sin-lowering-sin.f6432.6%

                    \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{sin.f64}\left(th\right)\right) \]
                13. Simplified32.6%

                  \[\leadsto \color{blue}{0 - \sin th} \]
              5. Recombined 3 regimes into one program.
              6. Add Preprocessing

              Alternative 16: 25.6% accurate, 6.7× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 6.6 \cdot 10^{-6}:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;\frac{ky \cdot th}{kx}\\ \end{array} \end{array} \]
              (FPCore (kx ky th)
               :precision binary64
               (if (<= kx 6.6e-6) (sin th) (/ (* ky th) kx)))
              double code(double kx, double ky, double th) {
              	double tmp;
              	if (kx <= 6.6e-6) {
              		tmp = sin(th);
              	} else {
              		tmp = (ky * th) / kx;
              	}
              	return tmp;
              }
              
              real(8) function code(kx, ky, th)
                  real(8), intent (in) :: kx
                  real(8), intent (in) :: ky
                  real(8), intent (in) :: th
                  real(8) :: tmp
                  if (kx <= 6.6d-6) then
                      tmp = sin(th)
                  else
                      tmp = (ky * th) / kx
                  end if
                  code = tmp
              end function
              
              public static double code(double kx, double ky, double th) {
              	double tmp;
              	if (kx <= 6.6e-6) {
              		tmp = Math.sin(th);
              	} else {
              		tmp = (ky * th) / kx;
              	}
              	return tmp;
              }
              
              def code(kx, ky, th):
              	tmp = 0
              	if kx <= 6.6e-6:
              		tmp = math.sin(th)
              	else:
              		tmp = (ky * th) / kx
              	return tmp
              
              function code(kx, ky, th)
              	tmp = 0.0
              	if (kx <= 6.6e-6)
              		tmp = sin(th);
              	else
              		tmp = Float64(Float64(ky * th) / kx);
              	end
              	return tmp
              end
              
              function tmp_2 = code(kx, ky, th)
              	tmp = 0.0;
              	if (kx <= 6.6e-6)
              		tmp = sin(th);
              	else
              		tmp = (ky * th) / kx;
              	end
              	tmp_2 = tmp;
              end
              
              code[kx_, ky_, th_] := If[LessEqual[kx, 6.6e-6], N[Sin[th], $MachinePrecision], N[(N[(ky * th), $MachinePrecision] / kx), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;kx \leq 6.6 \cdot 10^{-6}:\\
              \;\;\;\;\sin th\\
              
              \mathbf{else}:\\
              \;\;\;\;\frac{ky \cdot th}{kx}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if kx < 6.60000000000000034e-6

                1. Initial program 90.8%

                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                2. Step-by-step derivation
                  1. associate-*l/N/A

                    \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                  2. associate-/l*N/A

                    \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                  3. *-lowering-*.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\sin ky, \color{blue}{\left(\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right)}\right) \]
                  4. sin-lowering-sin.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\frac{\color{blue}{\sin th}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right) \]
                  5. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                  6. sin-lowering-sin.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                  7. +-commutativeN/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                  8. unpow2N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                  9. unpow2N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                  10. hypot-defineN/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                  11. hypot-lowering-hypot.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                  12. sin-lowering-sin.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                  13. sin-lowering-sin.f6499.6%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                3. Simplified99.6%

                  \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
                4. Add Preprocessing
                5. Taylor expanded in kx around 0

                  \[\leadsto \color{blue}{\sin th} \]
                6. Step-by-step derivation
                  1. sin-lowering-sin.f6430.6%

                    \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                7. Simplified30.6%

                  \[\leadsto \color{blue}{\sin th} \]

                if 6.60000000000000034e-6 < kx

                1. Initial program 99.3%

                  \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                2. Add Preprocessing
                3. Taylor expanded in th around 0

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{sin.f64}\left(kx\right), 2\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), \color{blue}{th}\right) \]
                4. Step-by-step derivation
                  1. Simplified44.5%

                    \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \color{blue}{th} \]
                  2. Taylor expanded in kx around 0

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\color{blue}{\left({kx}^{2}\right)}, \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), th\right) \]
                  3. Step-by-step derivation
                    1. unpow2N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(kx \cdot kx\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), th\right) \]
                    2. *-lowering-*.f6415.2%

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(kx, kx\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), th\right) \]
                  4. Simplified15.2%

                    \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{kx \cdot kx} + {\sin ky}^{2}}} \cdot th \]
                  5. Taylor expanded in ky around 0

                    \[\leadsto \color{blue}{\frac{ky \cdot th}{kx}} \]
                  6. Step-by-step derivation
                    1. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\left(ky \cdot th\right), \color{blue}{kx}\right) \]
                    2. *-lowering-*.f6415.3%

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(ky, th\right), kx\right) \]
                  7. Simplified15.3%

                    \[\leadsto \color{blue}{\frac{ky \cdot th}{kx}} \]
                5. Recombined 2 regimes into one program.
                6. Add Preprocessing

                Alternative 17: 16.6% accurate, 70.8× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 6.8 \cdot 10^{-6}:\\ \;\;\;\;th\\ \mathbf{else}:\\ \;\;\;\;\frac{ky \cdot th}{kx}\\ \end{array} \end{array} \]
                (FPCore (kx ky th) :precision binary64 (if (<= kx 6.8e-6) th (/ (* ky th) kx)))
                double code(double kx, double ky, double th) {
                	double tmp;
                	if (kx <= 6.8e-6) {
                		tmp = th;
                	} else {
                		tmp = (ky * th) / kx;
                	}
                	return tmp;
                }
                
                real(8) function code(kx, ky, th)
                    real(8), intent (in) :: kx
                    real(8), intent (in) :: ky
                    real(8), intent (in) :: th
                    real(8) :: tmp
                    if (kx <= 6.8d-6) then
                        tmp = th
                    else
                        tmp = (ky * th) / kx
                    end if
                    code = tmp
                end function
                
                public static double code(double kx, double ky, double th) {
                	double tmp;
                	if (kx <= 6.8e-6) {
                		tmp = th;
                	} else {
                		tmp = (ky * th) / kx;
                	}
                	return tmp;
                }
                
                def code(kx, ky, th):
                	tmp = 0
                	if kx <= 6.8e-6:
                		tmp = th
                	else:
                		tmp = (ky * th) / kx
                	return tmp
                
                function code(kx, ky, th)
                	tmp = 0.0
                	if (kx <= 6.8e-6)
                		tmp = th;
                	else
                		tmp = Float64(Float64(ky * th) / kx);
                	end
                	return tmp
                end
                
                function tmp_2 = code(kx, ky, th)
                	tmp = 0.0;
                	if (kx <= 6.8e-6)
                		tmp = th;
                	else
                		tmp = (ky * th) / kx;
                	end
                	tmp_2 = tmp;
                end
                
                code[kx_, ky_, th_] := If[LessEqual[kx, 6.8e-6], th, N[(N[(ky * th), $MachinePrecision] / kx), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;kx \leq 6.8 \cdot 10^{-6}:\\
                \;\;\;\;th\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{ky \cdot th}{kx}\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if kx < 6.80000000000000012e-6

                  1. Initial program 90.8%

                    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                  2. Step-by-step derivation
                    1. associate-*l/N/A

                      \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                    2. associate-/l*N/A

                      \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                    3. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\sin ky, \color{blue}{\left(\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right)}\right) \]
                    4. sin-lowering-sin.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\frac{\color{blue}{\sin th}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right) \]
                    5. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                    6. sin-lowering-sin.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                    7. +-commutativeN/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                    8. unpow2N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                    9. unpow2N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                    10. hypot-defineN/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                    11. hypot-lowering-hypot.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                    12. sin-lowering-sin.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                    13. sin-lowering-sin.f6499.6%

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                  3. Simplified99.6%

                    \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
                  4. Add Preprocessing
                  5. Taylor expanded in kx around 0

                    \[\leadsto \color{blue}{\sin th} \]
                  6. Step-by-step derivation
                    1. sin-lowering-sin.f6430.6%

                      \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                  7. Simplified30.6%

                    \[\leadsto \color{blue}{\sin th} \]
                  8. Taylor expanded in th around 0

                    \[\leadsto \color{blue}{th} \]
                  9. Step-by-step derivation
                    1. Simplified16.1%

                      \[\leadsto \color{blue}{th} \]

                    if 6.80000000000000012e-6 < kx

                    1. Initial program 99.3%

                      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                    2. Add Preprocessing
                    3. Taylor expanded in th around 0

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{sin.f64}\left(kx\right), 2\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), \color{blue}{th}\right) \]
                    4. Step-by-step derivation
                      1. Simplified44.5%

                        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \color{blue}{th} \]
                      2. Taylor expanded in kx around 0

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\color{blue}{\left({kx}^{2}\right)}, \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), th\right) \]
                      3. Step-by-step derivation
                        1. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(kx \cdot kx\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), th\right) \]
                        2. *-lowering-*.f6415.2%

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(kx, kx\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), th\right) \]
                      4. Simplified15.2%

                        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{kx \cdot kx} + {\sin ky}^{2}}} \cdot th \]
                      5. Taylor expanded in ky around 0

                        \[\leadsto \color{blue}{\frac{ky \cdot th}{kx}} \]
                      6. Step-by-step derivation
                        1. /-lowering-/.f64N/A

                          \[\leadsto \mathsf{/.f64}\left(\left(ky \cdot th\right), \color{blue}{kx}\right) \]
                        2. *-lowering-*.f6415.3%

                          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(ky, th\right), kx\right) \]
                      7. Simplified15.3%

                        \[\leadsto \color{blue}{\frac{ky \cdot th}{kx}} \]
                    5. Recombined 2 regimes into one program.
                    6. Add Preprocessing

                    Alternative 18: 16.6% accurate, 70.8× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;kx \leq 3.9 \cdot 10^{-7}:\\ \;\;\;\;th\\ \mathbf{else}:\\ \;\;\;\;ky \cdot \frac{th}{kx}\\ \end{array} \end{array} \]
                    (FPCore (kx ky th) :precision binary64 (if (<= kx 3.9e-7) th (* ky (/ th kx))))
                    double code(double kx, double ky, double th) {
                    	double tmp;
                    	if (kx <= 3.9e-7) {
                    		tmp = th;
                    	} else {
                    		tmp = ky * (th / kx);
                    	}
                    	return tmp;
                    }
                    
                    real(8) function code(kx, ky, th)
                        real(8), intent (in) :: kx
                        real(8), intent (in) :: ky
                        real(8), intent (in) :: th
                        real(8) :: tmp
                        if (kx <= 3.9d-7) then
                            tmp = th
                        else
                            tmp = ky * (th / kx)
                        end if
                        code = tmp
                    end function
                    
                    public static double code(double kx, double ky, double th) {
                    	double tmp;
                    	if (kx <= 3.9e-7) {
                    		tmp = th;
                    	} else {
                    		tmp = ky * (th / kx);
                    	}
                    	return tmp;
                    }
                    
                    def code(kx, ky, th):
                    	tmp = 0
                    	if kx <= 3.9e-7:
                    		tmp = th
                    	else:
                    		tmp = ky * (th / kx)
                    	return tmp
                    
                    function code(kx, ky, th)
                    	tmp = 0.0
                    	if (kx <= 3.9e-7)
                    		tmp = th;
                    	else
                    		tmp = Float64(ky * Float64(th / kx));
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(kx, ky, th)
                    	tmp = 0.0;
                    	if (kx <= 3.9e-7)
                    		tmp = th;
                    	else
                    		tmp = ky * (th / kx);
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[kx_, ky_, th_] := If[LessEqual[kx, 3.9e-7], th, N[(ky * N[(th / kx), $MachinePrecision]), $MachinePrecision]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;kx \leq 3.9 \cdot 10^{-7}:\\
                    \;\;\;\;th\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;ky \cdot \frac{th}{kx}\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if kx < 3.90000000000000025e-7

                      1. Initial program 90.8%

                        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                      2. Step-by-step derivation
                        1. associate-*l/N/A

                          \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                        2. associate-/l*N/A

                          \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                        3. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\sin ky, \color{blue}{\left(\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right)}\right) \]
                        4. sin-lowering-sin.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\frac{\color{blue}{\sin th}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right) \]
                        5. /-lowering-/.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                        6. sin-lowering-sin.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                        7. +-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                        8. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                        9. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                        10. hypot-defineN/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                        11. hypot-lowering-hypot.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                        12. sin-lowering-sin.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                        13. sin-lowering-sin.f6499.6%

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                      3. Simplified99.6%

                        \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
                      4. Add Preprocessing
                      5. Taylor expanded in kx around 0

                        \[\leadsto \color{blue}{\sin th} \]
                      6. Step-by-step derivation
                        1. sin-lowering-sin.f6430.6%

                          \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                      7. Simplified30.6%

                        \[\leadsto \color{blue}{\sin th} \]
                      8. Taylor expanded in th around 0

                        \[\leadsto \color{blue}{th} \]
                      9. Step-by-step derivation
                        1. Simplified16.1%

                          \[\leadsto \color{blue}{th} \]

                        if 3.90000000000000025e-7 < kx

                        1. Initial program 99.3%

                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                        2. Add Preprocessing
                        3. Taylor expanded in th around 0

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{sin.f64}\left(kx\right), 2\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), \color{blue}{th}\right) \]
                        4. Step-by-step derivation
                          1. Simplified44.5%

                            \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \color{blue}{th} \]
                          2. Taylor expanded in kx around 0

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\color{blue}{\left({kx}^{2}\right)}, \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), th\right) \]
                          3. Step-by-step derivation
                            1. unpow2N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\left(kx \cdot kx\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), th\right) \]
                            2. *-lowering-*.f6415.2%

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(kx, kx\right), \mathsf{pow.f64}\left(\mathsf{sin.f64}\left(ky\right), 2\right)\right)\right)\right), th\right) \]
                          4. Simplified15.2%

                            \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{kx \cdot kx} + {\sin ky}^{2}}} \cdot th \]
                          5. Taylor expanded in ky around 0

                            \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{ky}{kx}\right)}, th\right) \]
                          6. Step-by-step derivation
                            1. /-lowering-/.f6415.1%

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(ky, kx\right), th\right) \]
                          7. Simplified15.1%

                            \[\leadsto \color{blue}{\frac{ky}{kx}} \cdot th \]
                          8. Step-by-step derivation
                            1. associate-*l/N/A

                              \[\leadsto \frac{ky \cdot th}{\color{blue}{kx}} \]
                            2. associate-/l*N/A

                              \[\leadsto ky \cdot \color{blue}{\frac{th}{kx}} \]
                            3. *-lowering-*.f64N/A

                              \[\leadsto \mathsf{*.f64}\left(ky, \color{blue}{\left(\frac{th}{kx}\right)}\right) \]
                            4. /-lowering-/.f6415.3%

                              \[\leadsto \mathsf{*.f64}\left(ky, \mathsf{/.f64}\left(th, \color{blue}{kx}\right)\right) \]
                          9. Applied egg-rr15.3%

                            \[\leadsto \color{blue}{ky \cdot \frac{th}{kx}} \]
                        5. Recombined 2 regimes into one program.
                        6. Add Preprocessing

                        Alternative 19: 14.0% accurate, 709.0× speedup?

                        \[\begin{array}{l} \\ th \end{array} \]
                        (FPCore (kx ky th) :precision binary64 th)
                        double code(double kx, double ky, double th) {
                        	return th;
                        }
                        
                        real(8) function code(kx, ky, th)
                            real(8), intent (in) :: kx
                            real(8), intent (in) :: ky
                            real(8), intent (in) :: th
                            code = th
                        end function
                        
                        public static double code(double kx, double ky, double th) {
                        	return th;
                        }
                        
                        def code(kx, ky, th):
                        	return th
                        
                        function code(kx, ky, th)
                        	return th
                        end
                        
                        function tmp = code(kx, ky, th)
                        	tmp = th;
                        end
                        
                        code[kx_, ky_, th_] := th
                        
                        \begin{array}{l}
                        
                        \\
                        th
                        \end{array}
                        
                        Derivation
                        1. Initial program 92.8%

                          \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
                        2. Step-by-step derivation
                          1. associate-*l/N/A

                            \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                          2. associate-/l*N/A

                            \[\leadsto \sin ky \cdot \color{blue}{\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
                          3. *-lowering-*.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(\sin ky, \color{blue}{\left(\frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right)}\right) \]
                          4. sin-lowering-sin.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \left(\frac{\color{blue}{\sin th}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right) \]
                          5. /-lowering-/.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\sin th, \color{blue}{\left(\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}\right)\right) \]
                          6. sin-lowering-sin.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}\right)\right)\right) \]
                          7. +-commutativeN/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}\right)\right)\right) \]
                          8. unpow2N/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + {\sin kx}^{2}}\right)\right)\right) \]
                          9. unpow2N/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}\right)\right)\right) \]
                          10. hypot-defineN/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \left(\mathsf{hypot}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right)\right) \]
                          11. hypot-lowering-hypot.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\sin ky, \color{blue}{\sin kx}\right)\right)\right) \]
                          12. sin-lowering-sin.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \sin \color{blue}{kx}\right)\right)\right) \]
                          13. sin-lowering-sin.f6499.6%

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(th\right), \mathsf{hypot.f64}\left(\mathsf{sin.f64}\left(ky\right), \mathsf{sin.f64}\left(kx\right)\right)\right)\right) \]
                        3. Simplified99.6%

                          \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
                        4. Add Preprocessing
                        5. Taylor expanded in kx around 0

                          \[\leadsto \color{blue}{\sin th} \]
                        6. Step-by-step derivation
                          1. sin-lowering-sin.f6425.3%

                            \[\leadsto \mathsf{sin.f64}\left(th\right) \]
                        7. Simplified25.3%

                          \[\leadsto \color{blue}{\sin th} \]
                        8. Taylor expanded in th around 0

                          \[\leadsto \color{blue}{th} \]
                        9. Step-by-step derivation
                          1. Simplified13.6%

                            \[\leadsto \color{blue}{th} \]
                          2. Add Preprocessing

                          Reproduce

                          ?
                          herbie shell --seed 2024141 
                          (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)))