Toniolo and Linder, Equation (3b), real

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

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

Initial Program: 94.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.4× speedup?

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

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

    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
  2. Step-by-step derivation
    1. +-commutative95.9%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
    2. unpow295.9%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
    3. unpow295.9%

      \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
    4. hypot-def99.7%

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

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

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

Alternative 2: 78.8% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.1:\\
\;\;\;\;-\sin th\\

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

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


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

    1. Initial program 99.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative99.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow299.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow299.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.7%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\sin th \cdot \sin ky}{ky}} \]
    6. Step-by-step derivation
      1. mul-1-neg4.4%

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

        \[\leadsto -\color{blue}{\frac{\sin th}{\frac{ky}{\sin ky}}} \]
      3. distribute-neg-frac4.4%

        \[\leadsto \color{blue}{\frac{-\sin th}{\frac{ky}{\sin ky}}} \]
    7. Simplified4.4%

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

      \[\leadsto \color{blue}{-1 \cdot \sin th} \]
    9. Step-by-step derivation
      1. neg-mul-166.5%

        \[\leadsto \color{blue}{-\sin th} \]
    10. Simplified66.5%

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

    if -0.10000000000000001 < (sin.f64 ky) < 9.9999999999999998e-17

    1. Initial program 91.3%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative91.3%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow291.3%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow291.3%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

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

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

    if 9.9999999999999998e-17 < (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. +-commutative99.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow299.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow299.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.7%

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

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

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

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

Alternative 3: 55.4% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -1 \cdot 10^{-29}:\\
\;\;\;\;-\sin th\\

\mathbf{elif}\;\sin ky \leq 10^{-168}:\\
\;\;\;\;\frac{\frac{ky}{\sin kx}}{\frac{1}{\sin th}}\\

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


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

    1. Initial program 99.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative99.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow299.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow299.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\sin th \cdot \sin ky}{ky}} \]
    6. Step-by-step derivation
      1. mul-1-neg9.2%

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

        \[\leadsto -\color{blue}{\frac{\sin th}{\frac{ky}{\sin ky}}} \]
      3. distribute-neg-frac9.2%

        \[\leadsto \color{blue}{\frac{-\sin th}{\frac{ky}{\sin ky}}} \]
    7. Simplified9.2%

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

      \[\leadsto \color{blue}{-1 \cdot \sin th} \]
    9. Step-by-step derivation
      1. neg-mul-166.1%

        \[\leadsto \color{blue}{-\sin th} \]
    10. Simplified66.1%

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

    if -9.99999999999999943e-30 < (sin.f64 ky) < 1e-168

    1. Initial program 87.2%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative87.2%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow287.2%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow287.2%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

        \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}}} \]
      2. div-inv99.5%

        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \frac{1}{\sin th}}} \]
      3. associate-/r*99.6%

        \[\leadsto \color{blue}{\frac{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}}{\frac{1}{\sin th}}} \]
    5. Applied egg-rr99.6%

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

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

    if 1e-168 < (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/98.7%

        \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
      2. +-commutative98.7%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \]
      3. unpow298.7%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \]
      4. unpow298.7%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \]
      5. hypot-def98.7%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sin ky \leq -1 \cdot 10^{-29}:\\ \;\;\;\;-\sin th\\ \mathbf{elif}\;\sin ky \leq 10^{-168}:\\ \;\;\;\;\frac{\frac{ky}{\sin kx}}{\frac{1}{\sin th}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky \cdot \sin th}{\sin ky}\\ \end{array} \]

Alternative 4: 99.6% accurate, 1.4× speedup?

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
    2. associate-*r/95.8%

      \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
    3. +-commutative95.8%

      \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \]
    4. unpow295.8%

      \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \]
    5. unpow295.8%

      \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \]
    6. hypot-def99.6%

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

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

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

Alternative 5: 55.5% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq -1 \cdot 10^{-29}:\\ \;\;\;\;-\sin th\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-136}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= (sin ky) -1e-29)
   (- (sin th))
   (if (<= (sin ky) 5e-136) (* (sin th) (/ ky (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
	double tmp;
	if (sin(ky) <= -1e-29) {
		tmp = -sin(th);
	} else if (sin(ky) <= 5e-136) {
		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) <= (-1d-29)) then
        tmp = -sin(th)
    else if (sin(ky) <= 5d-136) 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) <= -1e-29) {
		tmp = -Math.sin(th);
	} else if (Math.sin(ky) <= 5e-136) {
		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) <= -1e-29:
		tmp = -math.sin(th)
	elif math.sin(ky) <= 5e-136:
		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) <= -1e-29)
		tmp = Float64(-sin(th));
	elseif (sin(ky) <= 5e-136)
		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) <= -1e-29)
		tmp = -sin(th);
	elseif (sin(ky) <= 5e-136)
		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], -1e-29], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-136], 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 -1 \cdot 10^{-29}:\\
\;\;\;\;-\sin th\\

\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-136}:\\
\;\;\;\;\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) < -9.99999999999999943e-30

    1. Initial program 99.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative99.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow299.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow299.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\sin th \cdot \sin ky}{ky}} \]
    6. Step-by-step derivation
      1. mul-1-neg9.2%

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

        \[\leadsto -\color{blue}{\frac{\sin th}{\frac{ky}{\sin ky}}} \]
      3. distribute-neg-frac9.2%

        \[\leadsto \color{blue}{\frac{-\sin th}{\frac{ky}{\sin ky}}} \]
    7. Simplified9.2%

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

      \[\leadsto \color{blue}{-1 \cdot \sin th} \]
    9. Step-by-step derivation
      1. neg-mul-166.1%

        \[\leadsto \color{blue}{-\sin th} \]
    10. Simplified66.1%

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

    if -9.99999999999999943e-30 < (sin.f64 ky) < 5.0000000000000002e-136

    1. Initial program 88.1%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative88.1%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow288.1%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow288.1%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

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

    if 5.0000000000000002e-136 < (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. +-commutative99.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow299.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow299.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sin ky \leq -1 \cdot 10^{-29}:\\ \;\;\;\;-\sin th\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-136}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]

Alternative 6: 55.5% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -1 \cdot 10^{-29}:\\
\;\;\;\;-\sin th\\

\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-136}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\

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


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

    1. Initial program 99.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative99.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow299.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow299.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\sin th \cdot \sin ky}{ky}} \]
    6. Step-by-step derivation
      1. mul-1-neg9.2%

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

        \[\leadsto -\color{blue}{\frac{\sin th}{\frac{ky}{\sin ky}}} \]
      3. distribute-neg-frac9.2%

        \[\leadsto \color{blue}{\frac{-\sin th}{\frac{ky}{\sin ky}}} \]
    7. Simplified9.2%

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

      \[\leadsto \color{blue}{-1 \cdot \sin th} \]
    9. Step-by-step derivation
      1. neg-mul-166.1%

        \[\leadsto \color{blue}{-\sin th} \]
    10. Simplified66.1%

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

    if -9.99999999999999943e-30 < (sin.f64 ky) < 5.0000000000000002e-136

    1. Initial program 88.1%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative88.1%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow288.1%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow288.1%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

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

        \[\leadsto \color{blue}{\frac{\sin th}{\frac{\sin kx}{ky}}} \]
    6. Simplified53.4%

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

    if 5.0000000000000002e-136 < (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. +-commutative99.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow299.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow299.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sin ky \leq -1 \cdot 10^{-29}:\\ \;\;\;\;-\sin th\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-136}:\\ \;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]

Alternative 7: 37.3% accurate, 6.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := -\sin th\\ \mathbf{if}\;ky \leq -1.1 \cdot 10^{+126}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;ky \leq -1800:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq -1.9 \cdot 10^{-135}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;ky \leq 1.8 \cdot 10^{-143}:\\ \;\;\;\;\frac{\frac{ky}{kx}}{\frac{1}{\sin th}}\\ \mathbf{elif}\;ky \leq 8 \cdot 10^{+58}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 1.05 \cdot 10^{+138}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (- (sin th))))
   (if (<= ky -1.1e+126)
     t_1
     (if (<= ky -1800.0)
       (sin th)
       (if (<= ky -1.9e-135)
         t_1
         (if (<= ky 1.8e-143)
           (/ (/ ky kx) (/ 1.0 (sin th)))
           (if (<= ky 8e+58)
             (sin th)
             (if (<= ky 1.05e+138) t_1 (sin th)))))))))
double code(double kx, double ky, double th) {
	double t_1 = -sin(th);
	double tmp;
	if (ky <= -1.1e+126) {
		tmp = t_1;
	} else if (ky <= -1800.0) {
		tmp = sin(th);
	} else if (ky <= -1.9e-135) {
		tmp = t_1;
	} else if (ky <= 1.8e-143) {
		tmp = (ky / kx) / (1.0 / sin(th));
	} else if (ky <= 8e+58) {
		tmp = sin(th);
	} else if (ky <= 1.05e+138) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_1 = -sin(th)
    if (ky <= (-1.1d+126)) then
        tmp = t_1
    else if (ky <= (-1800.0d0)) then
        tmp = sin(th)
    else if (ky <= (-1.9d-135)) then
        tmp = t_1
    else if (ky <= 1.8d-143) then
        tmp = (ky / kx) / (1.0d0 / sin(th))
    else if (ky <= 8d+58) then
        tmp = sin(th)
    else if (ky <= 1.05d+138) then
        tmp = t_1
    else
        tmp = sin(th)
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double t_1 = -Math.sin(th);
	double tmp;
	if (ky <= -1.1e+126) {
		tmp = t_1;
	} else if (ky <= -1800.0) {
		tmp = Math.sin(th);
	} else if (ky <= -1.9e-135) {
		tmp = t_1;
	} else if (ky <= 1.8e-143) {
		tmp = (ky / kx) / (1.0 / Math.sin(th));
	} else if (ky <= 8e+58) {
		tmp = Math.sin(th);
	} else if (ky <= 1.05e+138) {
		tmp = t_1;
	} else {
		tmp = Math.sin(th);
	}
	return tmp;
}
def code(kx, ky, th):
	t_1 = -math.sin(th)
	tmp = 0
	if ky <= -1.1e+126:
		tmp = t_1
	elif ky <= -1800.0:
		tmp = math.sin(th)
	elif ky <= -1.9e-135:
		tmp = t_1
	elif ky <= 1.8e-143:
		tmp = (ky / kx) / (1.0 / math.sin(th))
	elif ky <= 8e+58:
		tmp = math.sin(th)
	elif ky <= 1.05e+138:
		tmp = t_1
	else:
		tmp = math.sin(th)
	return tmp
function code(kx, ky, th)
	t_1 = Float64(-sin(th))
	tmp = 0.0
	if (ky <= -1.1e+126)
		tmp = t_1;
	elseif (ky <= -1800.0)
		tmp = sin(th);
	elseif (ky <= -1.9e-135)
		tmp = t_1;
	elseif (ky <= 1.8e-143)
		tmp = Float64(Float64(ky / kx) / Float64(1.0 / sin(th)));
	elseif (ky <= 8e+58)
		tmp = sin(th);
	elseif (ky <= 1.05e+138)
		tmp = t_1;
	else
		tmp = sin(th);
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	t_1 = -sin(th);
	tmp = 0.0;
	if (ky <= -1.1e+126)
		tmp = t_1;
	elseif (ky <= -1800.0)
		tmp = sin(th);
	elseif (ky <= -1.9e-135)
		tmp = t_1;
	elseif (ky <= 1.8e-143)
		tmp = (ky / kx) / (1.0 / sin(th));
	elseif (ky <= 8e+58)
		tmp = sin(th);
	elseif (ky <= 1.05e+138)
		tmp = t_1;
	else
		tmp = sin(th);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = (-N[Sin[th], $MachinePrecision])}, If[LessEqual[ky, -1.1e+126], t$95$1, If[LessEqual[ky, -1800.0], N[Sin[th], $MachinePrecision], If[LessEqual[ky, -1.9e-135], t$95$1, If[LessEqual[ky, 1.8e-143], N[(N[(ky / kx), $MachinePrecision] / N[(1.0 / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 8e+58], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 1.05e+138], t$95$1, N[Sin[th], $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := -\sin th\\
\mathbf{if}\;ky \leq -1.1 \cdot 10^{+126}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;ky \leq -1800:\\
\;\;\;\;\sin th\\

\mathbf{elif}\;ky \leq -1.9 \cdot 10^{-135}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;ky \leq 1.8 \cdot 10^{-143}:\\
\;\;\;\;\frac{\frac{ky}{kx}}{\frac{1}{\sin th}}\\

\mathbf{elif}\;ky \leq 8 \cdot 10^{+58}:\\
\;\;\;\;\sin th\\

\mathbf{elif}\;ky \leq 1.05 \cdot 10^{+138}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if ky < -1.09999999999999999e126 or -1800 < ky < -1.9000000000000001e-135 or 7.99999999999999955e58 < ky < 1.05000000000000003e138

    1. Initial program 99.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative99.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow299.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow299.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\sin th \cdot \sin ky}{ky}} \]
    6. Step-by-step derivation
      1. mul-1-neg16.5%

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

        \[\leadsto -\color{blue}{\frac{\sin th}{\frac{ky}{\sin ky}}} \]
      3. distribute-neg-frac16.6%

        \[\leadsto \color{blue}{\frac{-\sin th}{\frac{ky}{\sin ky}}} \]
    7. Simplified16.6%

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

      \[\leadsto \color{blue}{-1 \cdot \sin th} \]
    9. Step-by-step derivation
      1. neg-mul-146.8%

        \[\leadsto \color{blue}{-\sin th} \]
    10. Simplified46.8%

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

    if -1.09999999999999999e126 < ky < -1800 or 1.7999999999999999e-143 < ky < 7.99999999999999955e58 or 1.05000000000000003e138 < 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. +-commutative99.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow299.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow299.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.8%

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

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

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

    if -1.9000000000000001e-135 < ky < 1.7999999999999999e-143

    1. Initial program 83.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative83.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow283.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow283.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

        \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}}} \]
      2. div-inv99.5%

        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \frac{1}{\sin th}}} \]
      3. associate-/r*99.6%

        \[\leadsto \color{blue}{\frac{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}}{\frac{1}{\sin th}}} \]
    5. Applied egg-rr99.6%

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

      \[\leadsto \frac{\color{blue}{\frac{ky}{\sin kx}}}{\frac{1}{\sin th}} \]
    7. Taylor expanded in kx around 0 47.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq -1.1 \cdot 10^{+126}:\\ \;\;\;\;-\sin th\\ \mathbf{elif}\;ky \leq -1800:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq -1.9 \cdot 10^{-135}:\\ \;\;\;\;-\sin th\\ \mathbf{elif}\;ky \leq 1.8 \cdot 10^{-143}:\\ \;\;\;\;\frac{\frac{ky}{kx}}{\frac{1}{\sin th}}\\ \mathbf{elif}\;ky \leq 8 \cdot 10^{+58}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 1.05 \cdot 10^{+138}:\\ \;\;\;\;-\sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]

Alternative 8: 32.1% accurate, 6.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := -\sin th\\ \mathbf{if}\;ky \leq -1.1 \cdot 10^{+126}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;ky \leq -1800:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq -2.8 \cdot 10^{-152}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;ky \leq 3.6 \cdot 10^{-195}:\\ \;\;\;\;\sqrt{th \cdot th}\\ \mathbf{elif}\;ky \leq 8 \cdot 10^{+58}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 1.05 \cdot 10^{+138}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (- (sin th))))
   (if (<= ky -1.1e+126)
     t_1
     (if (<= ky -1800.0)
       (sin th)
       (if (<= ky -2.8e-152)
         t_1
         (if (<= ky 3.6e-195)
           (sqrt (* th th))
           (if (<= ky 8e+58)
             (sin th)
             (if (<= ky 1.05e+138) t_1 (sin th)))))))))
double code(double kx, double ky, double th) {
	double t_1 = -sin(th);
	double tmp;
	if (ky <= -1.1e+126) {
		tmp = t_1;
	} else if (ky <= -1800.0) {
		tmp = sin(th);
	} else if (ky <= -2.8e-152) {
		tmp = t_1;
	} else if (ky <= 3.6e-195) {
		tmp = sqrt((th * th));
	} else if (ky <= 8e+58) {
		tmp = sin(th);
	} else if (ky <= 1.05e+138) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_1 = -sin(th)
    if (ky <= (-1.1d+126)) then
        tmp = t_1
    else if (ky <= (-1800.0d0)) then
        tmp = sin(th)
    else if (ky <= (-2.8d-152)) then
        tmp = t_1
    else if (ky <= 3.6d-195) then
        tmp = sqrt((th * th))
    else if (ky <= 8d+58) then
        tmp = sin(th)
    else if (ky <= 1.05d+138) then
        tmp = t_1
    else
        tmp = sin(th)
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double t_1 = -Math.sin(th);
	double tmp;
	if (ky <= -1.1e+126) {
		tmp = t_1;
	} else if (ky <= -1800.0) {
		tmp = Math.sin(th);
	} else if (ky <= -2.8e-152) {
		tmp = t_1;
	} else if (ky <= 3.6e-195) {
		tmp = Math.sqrt((th * th));
	} else if (ky <= 8e+58) {
		tmp = Math.sin(th);
	} else if (ky <= 1.05e+138) {
		tmp = t_1;
	} else {
		tmp = Math.sin(th);
	}
	return tmp;
}
def code(kx, ky, th):
	t_1 = -math.sin(th)
	tmp = 0
	if ky <= -1.1e+126:
		tmp = t_1
	elif ky <= -1800.0:
		tmp = math.sin(th)
	elif ky <= -2.8e-152:
		tmp = t_1
	elif ky <= 3.6e-195:
		tmp = math.sqrt((th * th))
	elif ky <= 8e+58:
		tmp = math.sin(th)
	elif ky <= 1.05e+138:
		tmp = t_1
	else:
		tmp = math.sin(th)
	return tmp
function code(kx, ky, th)
	t_1 = Float64(-sin(th))
	tmp = 0.0
	if (ky <= -1.1e+126)
		tmp = t_1;
	elseif (ky <= -1800.0)
		tmp = sin(th);
	elseif (ky <= -2.8e-152)
		tmp = t_1;
	elseif (ky <= 3.6e-195)
		tmp = sqrt(Float64(th * th));
	elseif (ky <= 8e+58)
		tmp = sin(th);
	elseif (ky <= 1.05e+138)
		tmp = t_1;
	else
		tmp = sin(th);
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	t_1 = -sin(th);
	tmp = 0.0;
	if (ky <= -1.1e+126)
		tmp = t_1;
	elseif (ky <= -1800.0)
		tmp = sin(th);
	elseif (ky <= -2.8e-152)
		tmp = t_1;
	elseif (ky <= 3.6e-195)
		tmp = sqrt((th * th));
	elseif (ky <= 8e+58)
		tmp = sin(th);
	elseif (ky <= 1.05e+138)
		tmp = t_1;
	else
		tmp = sin(th);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = (-N[Sin[th], $MachinePrecision])}, If[LessEqual[ky, -1.1e+126], t$95$1, If[LessEqual[ky, -1800.0], N[Sin[th], $MachinePrecision], If[LessEqual[ky, -2.8e-152], t$95$1, If[LessEqual[ky, 3.6e-195], N[Sqrt[N[(th * th), $MachinePrecision]], $MachinePrecision], If[LessEqual[ky, 8e+58], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 1.05e+138], t$95$1, N[Sin[th], $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := -\sin th\\
\mathbf{if}\;ky \leq -1.1 \cdot 10^{+126}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;ky \leq -1800:\\
\;\;\;\;\sin th\\

\mathbf{elif}\;ky \leq -2.8 \cdot 10^{-152}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;ky \leq 3.6 \cdot 10^{-195}:\\
\;\;\;\;\sqrt{th \cdot th}\\

\mathbf{elif}\;ky \leq 8 \cdot 10^{+58}:\\
\;\;\;\;\sin th\\

\mathbf{elif}\;ky \leq 1.05 \cdot 10^{+138}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if ky < -1.09999999999999999e126 or -1800 < ky < -2.79999999999999984e-152 or 7.99999999999999955e58 < ky < 1.05000000000000003e138

    1. Initial program 99.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative99.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow299.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow299.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\sin th \cdot \sin ky}{ky}} \]
    6. Step-by-step derivation
      1. mul-1-neg15.9%

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

        \[\leadsto -\color{blue}{\frac{\sin th}{\frac{ky}{\sin ky}}} \]
      3. distribute-neg-frac15.9%

        \[\leadsto \color{blue}{\frac{-\sin th}{\frac{ky}{\sin ky}}} \]
    7. Simplified15.9%

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

      \[\leadsto \color{blue}{-1 \cdot \sin th} \]
    9. Step-by-step derivation
      1. neg-mul-144.4%

        \[\leadsto \color{blue}{-\sin th} \]
    10. Simplified44.4%

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

    if -1.09999999999999999e126 < ky < -1800 or 3.6e-195 < ky < 7.99999999999999955e58 or 1.05000000000000003e138 < ky

    1. Initial program 97.4%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative97.4%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow297.4%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow297.4%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.8%

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

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

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

    if -2.79999999999999984e-152 < ky < 3.6e-195

    1. Initial program 85.5%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative85.5%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow285.5%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow285.5%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

        \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}}} \]
      2. div-inv99.5%

        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \frac{1}{\sin th}}} \]
      3. associate-/r*99.6%

        \[\leadsto \color{blue}{\frac{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}}{\frac{1}{\sin th}}} \]
    5. Applied egg-rr99.6%

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

      \[\leadsto \frac{\color{blue}{1}}{\frac{1}{\sin th}} \]
    7. Taylor expanded in th around 0 4.8%

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{th}}} \]
    8. Step-by-step derivation
      1. remove-double-div4.8%

        \[\leadsto \color{blue}{th} \]
      2. add-sqr-sqrt2.8%

        \[\leadsto \color{blue}{\sqrt{th} \cdot \sqrt{th}} \]
      3. sqrt-unprod39.0%

        \[\leadsto \color{blue}{\sqrt{th \cdot th}} \]
    9. Applied egg-rr39.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq -1.1 \cdot 10^{+126}:\\ \;\;\;\;-\sin th\\ \mathbf{elif}\;ky \leq -1800:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq -2.8 \cdot 10^{-152}:\\ \;\;\;\;-\sin th\\ \mathbf{elif}\;ky \leq 3.6 \cdot 10^{-195}:\\ \;\;\;\;\sqrt{th \cdot th}\\ \mathbf{elif}\;ky \leq 8 \cdot 10^{+58}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 1.05 \cdot 10^{+138}:\\ \;\;\;\;-\sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]

Alternative 9: 35.6% accurate, 6.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := -\sin th\\ \mathbf{if}\;ky \leq -1.1 \cdot 10^{+126}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;ky \leq -1800:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq -3.7 \cdot 10^{-148}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;ky \leq 2.8 \cdot 10^{-195}:\\ \;\;\;\;\frac{ky}{\frac{\sin kx}{th}}\\ \mathbf{elif}\;ky \leq 8 \cdot 10^{+58}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 1.05 \cdot 10^{+138}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (- (sin th))))
   (if (<= ky -1.1e+126)
     t_1
     (if (<= ky -1800.0)
       (sin th)
       (if (<= ky -3.7e-148)
         t_1
         (if (<= ky 2.8e-195)
           (/ ky (/ (sin kx) th))
           (if (<= ky 8e+58)
             (sin th)
             (if (<= ky 1.05e+138) t_1 (sin th)))))))))
double code(double kx, double ky, double th) {
	double t_1 = -sin(th);
	double tmp;
	if (ky <= -1.1e+126) {
		tmp = t_1;
	} else if (ky <= -1800.0) {
		tmp = sin(th);
	} else if (ky <= -3.7e-148) {
		tmp = t_1;
	} else if (ky <= 2.8e-195) {
		tmp = ky / (sin(kx) / th);
	} else if (ky <= 8e+58) {
		tmp = sin(th);
	} else if (ky <= 1.05e+138) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_1 = -sin(th)
    if (ky <= (-1.1d+126)) then
        tmp = t_1
    else if (ky <= (-1800.0d0)) then
        tmp = sin(th)
    else if (ky <= (-3.7d-148)) then
        tmp = t_1
    else if (ky <= 2.8d-195) then
        tmp = ky / (sin(kx) / th)
    else if (ky <= 8d+58) then
        tmp = sin(th)
    else if (ky <= 1.05d+138) then
        tmp = t_1
    else
        tmp = sin(th)
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double t_1 = -Math.sin(th);
	double tmp;
	if (ky <= -1.1e+126) {
		tmp = t_1;
	} else if (ky <= -1800.0) {
		tmp = Math.sin(th);
	} else if (ky <= -3.7e-148) {
		tmp = t_1;
	} else if (ky <= 2.8e-195) {
		tmp = ky / (Math.sin(kx) / th);
	} else if (ky <= 8e+58) {
		tmp = Math.sin(th);
	} else if (ky <= 1.05e+138) {
		tmp = t_1;
	} else {
		tmp = Math.sin(th);
	}
	return tmp;
}
def code(kx, ky, th):
	t_1 = -math.sin(th)
	tmp = 0
	if ky <= -1.1e+126:
		tmp = t_1
	elif ky <= -1800.0:
		tmp = math.sin(th)
	elif ky <= -3.7e-148:
		tmp = t_1
	elif ky <= 2.8e-195:
		tmp = ky / (math.sin(kx) / th)
	elif ky <= 8e+58:
		tmp = math.sin(th)
	elif ky <= 1.05e+138:
		tmp = t_1
	else:
		tmp = math.sin(th)
	return tmp
function code(kx, ky, th)
	t_1 = Float64(-sin(th))
	tmp = 0.0
	if (ky <= -1.1e+126)
		tmp = t_1;
	elseif (ky <= -1800.0)
		tmp = sin(th);
	elseif (ky <= -3.7e-148)
		tmp = t_1;
	elseif (ky <= 2.8e-195)
		tmp = Float64(ky / Float64(sin(kx) / th));
	elseif (ky <= 8e+58)
		tmp = sin(th);
	elseif (ky <= 1.05e+138)
		tmp = t_1;
	else
		tmp = sin(th);
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	t_1 = -sin(th);
	tmp = 0.0;
	if (ky <= -1.1e+126)
		tmp = t_1;
	elseif (ky <= -1800.0)
		tmp = sin(th);
	elseif (ky <= -3.7e-148)
		tmp = t_1;
	elseif (ky <= 2.8e-195)
		tmp = ky / (sin(kx) / th);
	elseif (ky <= 8e+58)
		tmp = sin(th);
	elseif (ky <= 1.05e+138)
		tmp = t_1;
	else
		tmp = sin(th);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = (-N[Sin[th], $MachinePrecision])}, If[LessEqual[ky, -1.1e+126], t$95$1, If[LessEqual[ky, -1800.0], N[Sin[th], $MachinePrecision], If[LessEqual[ky, -3.7e-148], t$95$1, If[LessEqual[ky, 2.8e-195], N[(ky / N[(N[Sin[kx], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 8e+58], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 1.05e+138], t$95$1, N[Sin[th], $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := -\sin th\\
\mathbf{if}\;ky \leq -1.1 \cdot 10^{+126}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;ky \leq -1800:\\
\;\;\;\;\sin th\\

\mathbf{elif}\;ky \leq -3.7 \cdot 10^{-148}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;ky \leq 2.8 \cdot 10^{-195}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{th}}\\

\mathbf{elif}\;ky \leq 8 \cdot 10^{+58}:\\
\;\;\;\;\sin th\\

\mathbf{elif}\;ky \leq 1.05 \cdot 10^{+138}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if ky < -1.09999999999999999e126 or -1800 < ky < -3.70000000000000034e-148 or 7.99999999999999955e58 < ky < 1.05000000000000003e138

    1. Initial program 99.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative99.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow299.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow299.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\sin th \cdot \sin ky}{ky}} \]
    6. Step-by-step derivation
      1. mul-1-neg16.3%

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

        \[\leadsto -\color{blue}{\frac{\sin th}{\frac{ky}{\sin ky}}} \]
      3. distribute-neg-frac16.3%

        \[\leadsto \color{blue}{\frac{-\sin th}{\frac{ky}{\sin ky}}} \]
    7. Simplified16.3%

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

      \[\leadsto \color{blue}{-1 \cdot \sin th} \]
    9. Step-by-step derivation
      1. neg-mul-145.8%

        \[\leadsto \color{blue}{-\sin th} \]
    10. Simplified45.8%

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

    if -1.09999999999999999e126 < ky < -1800 or 2.80000000000000003e-195 < ky < 7.99999999999999955e58 or 1.05000000000000003e138 < ky

    1. Initial program 97.4%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative97.4%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow297.4%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow297.4%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.8%

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

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

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

    if -3.70000000000000034e-148 < ky < 2.80000000000000003e-195

    1. Initial program 86.3%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative86.3%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow286.3%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow286.3%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

        \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}}} \]
      2. div-inv99.5%

        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \frac{1}{\sin th}}} \]
      3. associate-/r*99.6%

        \[\leadsto \color{blue}{\frac{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}}{\frac{1}{\sin th}}} \]
    5. Applied egg-rr99.6%

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

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

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

        \[\leadsto \color{blue}{\frac{ky}{\frac{\sin kx}{th}}} \]
    9. Simplified43.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq -1.1 \cdot 10^{+126}:\\ \;\;\;\;-\sin th\\ \mathbf{elif}\;ky \leq -1800:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq -3.7 \cdot 10^{-148}:\\ \;\;\;\;-\sin th\\ \mathbf{elif}\;ky \leq 2.8 \cdot 10^{-195}:\\ \;\;\;\;\frac{ky}{\frac{\sin kx}{th}}\\ \mathbf{elif}\;ky \leq 8 \cdot 10^{+58}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 1.05 \cdot 10^{+138}:\\ \;\;\;\;-\sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]

Alternative 10: 37.4% accurate, 6.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := -\sin th\\ \mathbf{if}\;ky \leq -1.1 \cdot 10^{+126}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;ky \leq -1800:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq -6 \cdot 10^{-136}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;ky \leq 2.6 \cdot 10^{-144}:\\ \;\;\;\;\frac{\sin th}{\frac{kx}{ky}}\\ \mathbf{elif}\;ky \leq 8 \cdot 10^{+58}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 1.05 \cdot 10^{+138}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (- (sin th))))
   (if (<= ky -1.1e+126)
     t_1
     (if (<= ky -1800.0)
       (sin th)
       (if (<= ky -6e-136)
         t_1
         (if (<= ky 2.6e-144)
           (/ (sin th) (/ kx ky))
           (if (<= ky 8e+58)
             (sin th)
             (if (<= ky 1.05e+138) t_1 (sin th)))))))))
double code(double kx, double ky, double th) {
	double t_1 = -sin(th);
	double tmp;
	if (ky <= -1.1e+126) {
		tmp = t_1;
	} else if (ky <= -1800.0) {
		tmp = sin(th);
	} else if (ky <= -6e-136) {
		tmp = t_1;
	} else if (ky <= 2.6e-144) {
		tmp = sin(th) / (kx / ky);
	} else if (ky <= 8e+58) {
		tmp = sin(th);
	} else if (ky <= 1.05e+138) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_1 = -sin(th)
    if (ky <= (-1.1d+126)) then
        tmp = t_1
    else if (ky <= (-1800.0d0)) then
        tmp = sin(th)
    else if (ky <= (-6d-136)) then
        tmp = t_1
    else if (ky <= 2.6d-144) then
        tmp = sin(th) / (kx / ky)
    else if (ky <= 8d+58) then
        tmp = sin(th)
    else if (ky <= 1.05d+138) then
        tmp = t_1
    else
        tmp = sin(th)
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double t_1 = -Math.sin(th);
	double tmp;
	if (ky <= -1.1e+126) {
		tmp = t_1;
	} else if (ky <= -1800.0) {
		tmp = Math.sin(th);
	} else if (ky <= -6e-136) {
		tmp = t_1;
	} else if (ky <= 2.6e-144) {
		tmp = Math.sin(th) / (kx / ky);
	} else if (ky <= 8e+58) {
		tmp = Math.sin(th);
	} else if (ky <= 1.05e+138) {
		tmp = t_1;
	} else {
		tmp = Math.sin(th);
	}
	return tmp;
}
def code(kx, ky, th):
	t_1 = -math.sin(th)
	tmp = 0
	if ky <= -1.1e+126:
		tmp = t_1
	elif ky <= -1800.0:
		tmp = math.sin(th)
	elif ky <= -6e-136:
		tmp = t_1
	elif ky <= 2.6e-144:
		tmp = math.sin(th) / (kx / ky)
	elif ky <= 8e+58:
		tmp = math.sin(th)
	elif ky <= 1.05e+138:
		tmp = t_1
	else:
		tmp = math.sin(th)
	return tmp
function code(kx, ky, th)
	t_1 = Float64(-sin(th))
	tmp = 0.0
	if (ky <= -1.1e+126)
		tmp = t_1;
	elseif (ky <= -1800.0)
		tmp = sin(th);
	elseif (ky <= -6e-136)
		tmp = t_1;
	elseif (ky <= 2.6e-144)
		tmp = Float64(sin(th) / Float64(kx / ky));
	elseif (ky <= 8e+58)
		tmp = sin(th);
	elseif (ky <= 1.05e+138)
		tmp = t_1;
	else
		tmp = sin(th);
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	t_1 = -sin(th);
	tmp = 0.0;
	if (ky <= -1.1e+126)
		tmp = t_1;
	elseif (ky <= -1800.0)
		tmp = sin(th);
	elseif (ky <= -6e-136)
		tmp = t_1;
	elseif (ky <= 2.6e-144)
		tmp = sin(th) / (kx / ky);
	elseif (ky <= 8e+58)
		tmp = sin(th);
	elseif (ky <= 1.05e+138)
		tmp = t_1;
	else
		tmp = sin(th);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = (-N[Sin[th], $MachinePrecision])}, If[LessEqual[ky, -1.1e+126], t$95$1, If[LessEqual[ky, -1800.0], N[Sin[th], $MachinePrecision], If[LessEqual[ky, -6e-136], t$95$1, If[LessEqual[ky, 2.6e-144], N[(N[Sin[th], $MachinePrecision] / N[(kx / ky), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 8e+58], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 1.05e+138], t$95$1, N[Sin[th], $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := -\sin th\\
\mathbf{if}\;ky \leq -1.1 \cdot 10^{+126}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;ky \leq -1800:\\
\;\;\;\;\sin th\\

\mathbf{elif}\;ky \leq -6 \cdot 10^{-136}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;ky \leq 2.6 \cdot 10^{-144}:\\
\;\;\;\;\frac{\sin th}{\frac{kx}{ky}}\\

\mathbf{elif}\;ky \leq 8 \cdot 10^{+58}:\\
\;\;\;\;\sin th\\

\mathbf{elif}\;ky \leq 1.05 \cdot 10^{+138}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if ky < -1.09999999999999999e126 or -1800 < ky < -5.9999999999999996e-136 or 7.99999999999999955e58 < ky < 1.05000000000000003e138

    1. Initial program 99.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative99.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow299.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow299.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\sin th \cdot \sin ky}{ky}} \]
    6. Step-by-step derivation
      1. mul-1-neg16.5%

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

        \[\leadsto -\color{blue}{\frac{\sin th}{\frac{ky}{\sin ky}}} \]
      3. distribute-neg-frac16.6%

        \[\leadsto \color{blue}{\frac{-\sin th}{\frac{ky}{\sin ky}}} \]
    7. Simplified16.6%

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

      \[\leadsto \color{blue}{-1 \cdot \sin th} \]
    9. Step-by-step derivation
      1. neg-mul-146.8%

        \[\leadsto \color{blue}{-\sin th} \]
    10. Simplified46.8%

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

    if -1.09999999999999999e126 < ky < -1800 or 2.6000000000000001e-144 < ky < 7.99999999999999955e58 or 1.05000000000000003e138 < 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. +-commutative99.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow299.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow299.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.8%

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

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

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

    if -5.9999999999999996e-136 < ky < 2.6000000000000001e-144

    1. Initial program 83.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative83.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow283.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow283.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

        \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}}} \]
      2. div-inv99.5%

        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \frac{1}{\sin th}}} \]
      3. associate-/r*99.6%

        \[\leadsto \color{blue}{\frac{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}}{\frac{1}{\sin th}}} \]
    5. Applied egg-rr99.6%

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

      \[\leadsto \frac{\color{blue}{\frac{ky}{\sin kx}}}{\frac{1}{\sin th}} \]
    7. Taylor expanded in kx around 0 45.8%

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

        \[\leadsto \color{blue}{\frac{\sin th}{\frac{kx}{ky}}} \]
    9. Simplified47.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq -1.1 \cdot 10^{+126}:\\ \;\;\;\;-\sin th\\ \mathbf{elif}\;ky \leq -1800:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq -6 \cdot 10^{-136}:\\ \;\;\;\;-\sin th\\ \mathbf{elif}\;ky \leq 2.6 \cdot 10^{-144}:\\ \;\;\;\;\frac{\sin th}{\frac{kx}{ky}}\\ \mathbf{elif}\;ky \leq 8 \cdot 10^{+58}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 1.05 \cdot 10^{+138}:\\ \;\;\;\;-\sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]

Alternative 11: 30.8% accurate, 6.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq -1.1 \cdot 10^{+126} \lor \neg \left(ky \leq -1800\right) \land \left(ky \leq -5 \cdot 10^{-310} \lor \neg \left(ky \leq 8 \cdot 10^{+58}\right) \land ky \leq 1.05 \cdot 10^{+138}\right):\\ \;\;\;\;-\sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (or (<= ky -1.1e+126)
         (and (not (<= ky -1800.0))
              (or (<= ky -5e-310)
                  (and (not (<= ky 8e+58)) (<= ky 1.05e+138)))))
   (- (sin th))
   (sin th)))
double code(double kx, double ky, double th) {
	double tmp;
	if ((ky <= -1.1e+126) || (!(ky <= -1800.0) && ((ky <= -5e-310) || (!(ky <= 8e+58) && (ky <= 1.05e+138))))) {
		tmp = -sin(th);
	} else {
		tmp = sin(th);
	}
	return tmp;
}
real(8) function code(kx, ky, th)
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    real(8) :: tmp
    if ((ky <= (-1.1d+126)) .or. (.not. (ky <= (-1800.0d0))) .and. (ky <= (-5d-310)) .or. (.not. (ky <= 8d+58)) .and. (ky <= 1.05d+138)) then
        tmp = -sin(th)
    else
        tmp = sin(th)
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double tmp;
	if ((ky <= -1.1e+126) || (!(ky <= -1800.0) && ((ky <= -5e-310) || (!(ky <= 8e+58) && (ky <= 1.05e+138))))) {
		tmp = -Math.sin(th);
	} else {
		tmp = Math.sin(th);
	}
	return tmp;
}
def code(kx, ky, th):
	tmp = 0
	if (ky <= -1.1e+126) or (not (ky <= -1800.0) and ((ky <= -5e-310) or (not (ky <= 8e+58) and (ky <= 1.05e+138)))):
		tmp = -math.sin(th)
	else:
		tmp = math.sin(th)
	return tmp
function code(kx, ky, th)
	tmp = 0.0
	if ((ky <= -1.1e+126) || (!(ky <= -1800.0) && ((ky <= -5e-310) || (!(ky <= 8e+58) && (ky <= 1.05e+138)))))
		tmp = Float64(-sin(th));
	else
		tmp = sin(th);
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	tmp = 0.0;
	if ((ky <= -1.1e+126) || (~((ky <= -1800.0)) && ((ky <= -5e-310) || (~((ky <= 8e+58)) && (ky <= 1.05e+138)))))
		tmp = -sin(th);
	else
		tmp = sin(th);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := If[Or[LessEqual[ky, -1.1e+126], And[N[Not[LessEqual[ky, -1800.0]], $MachinePrecision], Or[LessEqual[ky, -5e-310], And[N[Not[LessEqual[ky, 8e+58]], $MachinePrecision], LessEqual[ky, 1.05e+138]]]]], (-N[Sin[th], $MachinePrecision]), N[Sin[th], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;ky \leq -1.1 \cdot 10^{+126} \lor \neg \left(ky \leq -1800\right) \land \left(ky \leq -5 \cdot 10^{-310} \lor \neg \left(ky \leq 8 \cdot 10^{+58}\right) \land ky \leq 1.05 \cdot 10^{+138}\right):\\
\;\;\;\;-\sin th\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < -1.09999999999999999e126 or -1800 < ky < -4.999999999999985e-310 or 7.99999999999999955e58 < ky < 1.05000000000000003e138

    1. Initial program 96.2%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative96.2%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow296.2%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow296.2%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\sin th \cdot \sin ky}{ky}} \]
    6. Step-by-step derivation
      1. mul-1-neg24.6%

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

        \[\leadsto -\color{blue}{\frac{\sin th}{\frac{ky}{\sin ky}}} \]
      3. distribute-neg-frac15.7%

        \[\leadsto \color{blue}{\frac{-\sin th}{\frac{ky}{\sin ky}}} \]
    7. Simplified15.7%

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

      \[\leadsto \color{blue}{-1 \cdot \sin th} \]
    9. Step-by-step derivation
      1. neg-mul-136.8%

        \[\leadsto \color{blue}{-\sin th} \]
    10. Simplified36.8%

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

    if -1.09999999999999999e126 < ky < -1800 or -4.999999999999985e-310 < ky < 7.99999999999999955e58 or 1.05000000000000003e138 < ky

    1. Initial program 95.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative95.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow295.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow295.6%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.7%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq -1.1 \cdot 10^{+126} \lor \neg \left(ky \leq -1800\right) \land \left(ky \leq -5 \cdot 10^{-310} \lor \neg \left(ky \leq 8 \cdot 10^{+58}\right) \land ky \leq 1.05 \cdot 10^{+138}\right):\\ \;\;\;\;-\sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]

Alternative 12: 23.8% accurate, 6.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;th \leq 9.2 \cdot 10^{-306}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;th \leq 1.4 \cdot 10^{-50}:\\ \;\;\;\;-th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= th 9.2e-306) (sin th) (if (<= th 1.4e-50) (- th) (sin th))))
double code(double kx, double ky, double th) {
	double tmp;
	if (th <= 9.2e-306) {
		tmp = sin(th);
	} else if (th <= 1.4e-50) {
		tmp = -th;
	} else {
		tmp = sin(th);
	}
	return tmp;
}
real(8) function code(kx, ky, th)
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    real(8) :: tmp
    if (th <= 9.2d-306) then
        tmp = sin(th)
    else if (th <= 1.4d-50) then
        tmp = -th
    else
        tmp = sin(th)
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double tmp;
	if (th <= 9.2e-306) {
		tmp = Math.sin(th);
	} else if (th <= 1.4e-50) {
		tmp = -th;
	} else {
		tmp = Math.sin(th);
	}
	return tmp;
}
def code(kx, ky, th):
	tmp = 0
	if th <= 9.2e-306:
		tmp = math.sin(th)
	elif th <= 1.4e-50:
		tmp = -th
	else:
		tmp = math.sin(th)
	return tmp
function code(kx, ky, th)
	tmp = 0.0
	if (th <= 9.2e-306)
		tmp = sin(th);
	elseif (th <= 1.4e-50)
		tmp = Float64(-th);
	else
		tmp = sin(th);
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	tmp = 0.0;
	if (th <= 9.2e-306)
		tmp = sin(th);
	elseif (th <= 1.4e-50)
		tmp = -th;
	else
		tmp = sin(th);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := If[LessEqual[th, 9.2e-306], N[Sin[th], $MachinePrecision], If[LessEqual[th, 1.4e-50], (-th), N[Sin[th], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;th \leq 9.2 \cdot 10^{-306}:\\
\;\;\;\;\sin th\\

\mathbf{elif}\;th \leq 1.4 \cdot 10^{-50}:\\
\;\;\;\;-th\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if th < 9.19999999999999956e-306 or 1.3999999999999999e-50 < th

    1. Initial program 95.5%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative95.5%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow295.5%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow295.5%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

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

    if 9.19999999999999956e-306 < th < 1.3999999999999999e-50

    1. Initial program 97.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative97.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow297.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow297.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.8%

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

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

        \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}}} \]
      2. div-inv99.7%

        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \frac{1}{\sin th}}} \]
      3. associate-/r*99.8%

        \[\leadsto \color{blue}{\frac{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}}{\frac{1}{\sin th}}} \]
    5. Applied egg-rr99.8%

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

      \[\leadsto \frac{\color{blue}{1}}{\frac{1}{\sin th}} \]
    7. Step-by-step derivation
      1. remove-double-div15.3%

        \[\leadsto \color{blue}{\sin th} \]
      2. remove-double-neg15.3%

        \[\leadsto \color{blue}{-\left(-\sin th\right)} \]
      3. add-sqr-sqrt0.0%

        \[\leadsto -\color{blue}{\sqrt{-\sin th} \cdot \sqrt{-\sin th}} \]
      4. sqrt-unprod49.5%

        \[\leadsto -\color{blue}{\sqrt{\left(-\sin th\right) \cdot \left(-\sin th\right)}} \]
      5. sqr-neg49.5%

        \[\leadsto -\sqrt{\color{blue}{\sin th \cdot \sin th}} \]
      6. sqrt-unprod33.2%

        \[\leadsto -\color{blue}{\sqrt{\sin th} \cdot \sqrt{\sin th}} \]
      7. distribute-rgt-neg-in33.2%

        \[\leadsto \color{blue}{\sqrt{\sin th} \cdot \left(-\sqrt{\sin th}\right)} \]
    8. Applied egg-rr33.2%

      \[\leadsto \color{blue}{\sqrt{\sin th} \cdot \left(-\sqrt{\sin th}\right)} \]
    9. Taylor expanded in th around 0 33.4%

      \[\leadsto \color{blue}{-1 \cdot th} \]
    10. Step-by-step derivation
      1. neg-mul-133.4%

        \[\leadsto \color{blue}{-th} \]
    11. Simplified33.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;th \leq 9.2 \cdot 10^{-306}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;th \leq 1.4 \cdot 10^{-50}:\\ \;\;\;\;-th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]

Alternative 13: 17.2% accurate, 64.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq -5.9 \cdot 10^{-238}:\\ \;\;\;\;-th\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{th} + th \cdot 0.16666666666666666}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= ky -5.9e-238)
   (- th)
   (/ 1.0 (+ (/ 1.0 th) (* th 0.16666666666666666)))))
double code(double kx, double ky, double th) {
	double tmp;
	if (ky <= -5.9e-238) {
		tmp = -th;
	} else {
		tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
	}
	return tmp;
}
real(8) function code(kx, ky, th)
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    real(8) :: tmp
    if (ky <= (-5.9d-238)) then
        tmp = -th
    else
        tmp = 1.0d0 / ((1.0d0 / th) + (th * 0.16666666666666666d0))
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double tmp;
	if (ky <= -5.9e-238) {
		tmp = -th;
	} else {
		tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
	}
	return tmp;
}
def code(kx, ky, th):
	tmp = 0
	if ky <= -5.9e-238:
		tmp = -th
	else:
		tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666))
	return tmp
function code(kx, ky, th)
	tmp = 0.0
	if (ky <= -5.9e-238)
		tmp = Float64(-th);
	else
		tmp = Float64(1.0 / Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)));
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	tmp = 0.0;
	if (ky <= -5.9e-238)
		tmp = -th;
	else
		tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := If[LessEqual[ky, -5.9e-238], (-th), N[(1.0 / N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;ky \leq -5.9 \cdot 10^{-238}:\\
\;\;\;\;-th\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{th} + th \cdot 0.16666666666666666}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < -5.8999999999999998e-238

    1. Initial program 97.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative97.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow297.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow297.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

        \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}}} \]
      2. div-inv99.5%

        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \frac{1}{\sin th}}} \]
      3. associate-/r*99.4%

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

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

      \[\leadsto \frac{\color{blue}{1}}{\frac{1}{\sin th}} \]
    7. Step-by-step derivation
      1. remove-double-div17.7%

        \[\leadsto \color{blue}{\sin th} \]
      2. remove-double-neg17.7%

        \[\leadsto \color{blue}{-\left(-\sin th\right)} \]
      3. add-sqr-sqrt13.0%

        \[\leadsto -\color{blue}{\sqrt{-\sin th} \cdot \sqrt{-\sin th}} \]
      4. sqrt-unprod30.8%

        \[\leadsto -\color{blue}{\sqrt{\left(-\sin th\right) \cdot \left(-\sin th\right)}} \]
      5. sqr-neg30.8%

        \[\leadsto -\sqrt{\color{blue}{\sin th \cdot \sin th}} \]
      6. sqrt-unprod16.4%

        \[\leadsto -\color{blue}{\sqrt{\sin th} \cdot \sqrt{\sin th}} \]
      7. distribute-rgt-neg-in16.4%

        \[\leadsto \color{blue}{\sqrt{\sin th} \cdot \left(-\sqrt{\sin th}\right)} \]
    8. Applied egg-rr16.4%

      \[\leadsto \color{blue}{\sqrt{\sin th} \cdot \left(-\sqrt{\sin th}\right)} \]
    9. Taylor expanded in th around 0 19.3%

      \[\leadsto \color{blue}{-1 \cdot th} \]
    10. Step-by-step derivation
      1. neg-mul-119.3%

        \[\leadsto \color{blue}{-th} \]
    11. Simplified19.3%

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

    if -5.8999999999999998e-238 < ky

    1. Initial program 94.5%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative94.5%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow294.5%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow294.5%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.8%

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

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

        \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}}} \]
      2. div-inv99.5%

        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \frac{1}{\sin th}}} \]
      3. associate-/r*99.6%

        \[\leadsto \color{blue}{\frac{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}}{\frac{1}{\sin th}}} \]
    5. Applied egg-rr99.6%

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

      \[\leadsto \frac{\color{blue}{1}}{\frac{1}{\sin th}} \]
    7. Taylor expanded in th around 0 18.0%

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{th} + 0.16666666666666666 \cdot th}} \]
    8. Step-by-step derivation
      1. *-commutative18.0%

        \[\leadsto \frac{1}{\frac{1}{th} + \color{blue}{th \cdot 0.16666666666666666}} \]
    9. Simplified18.0%

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{th} + th \cdot 0.16666666666666666}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification18.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq -5.9 \cdot 10^{-238}:\\ \;\;\;\;-th\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{th} + th \cdot 0.16666666666666666}\\ \end{array} \]

Alternative 14: 16.8% accurate, 174.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq -5.9 \cdot 10^{-238}:\\ \;\;\;\;-th\\ \mathbf{else}:\\ \;\;\;\;th\\ \end{array} \end{array} \]
(FPCore (kx ky th) :precision binary64 (if (<= ky -5.9e-238) (- th) th))
double code(double kx, double ky, double th) {
	double tmp;
	if (ky <= -5.9e-238) {
		tmp = -th;
	} else {
		tmp = th;
	}
	return tmp;
}
real(8) function code(kx, ky, th)
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    real(8) :: tmp
    if (ky <= (-5.9d-238)) then
        tmp = -th
    else
        tmp = th
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double tmp;
	if (ky <= -5.9e-238) {
		tmp = -th;
	} else {
		tmp = th;
	}
	return tmp;
}
def code(kx, ky, th):
	tmp = 0
	if ky <= -5.9e-238:
		tmp = -th
	else:
		tmp = th
	return tmp
function code(kx, ky, th)
	tmp = 0.0
	if (ky <= -5.9e-238)
		tmp = Float64(-th);
	else
		tmp = th;
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	tmp = 0.0;
	if (ky <= -5.9e-238)
		tmp = -th;
	else
		tmp = th;
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := If[LessEqual[ky, -5.9e-238], (-th), th]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;ky \leq -5.9 \cdot 10^{-238}:\\
\;\;\;\;-th\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < -5.8999999999999998e-238

    1. Initial program 97.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative97.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow297.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow297.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.6%

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

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

        \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}}} \]
      2. div-inv99.5%

        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \frac{1}{\sin th}}} \]
      3. associate-/r*99.4%

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

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

      \[\leadsto \frac{\color{blue}{1}}{\frac{1}{\sin th}} \]
    7. Step-by-step derivation
      1. remove-double-div17.7%

        \[\leadsto \color{blue}{\sin th} \]
      2. remove-double-neg17.7%

        \[\leadsto \color{blue}{-\left(-\sin th\right)} \]
      3. add-sqr-sqrt13.0%

        \[\leadsto -\color{blue}{\sqrt{-\sin th} \cdot \sqrt{-\sin th}} \]
      4. sqrt-unprod30.8%

        \[\leadsto -\color{blue}{\sqrt{\left(-\sin th\right) \cdot \left(-\sin th\right)}} \]
      5. sqr-neg30.8%

        \[\leadsto -\sqrt{\color{blue}{\sin th \cdot \sin th}} \]
      6. sqrt-unprod16.4%

        \[\leadsto -\color{blue}{\sqrt{\sin th} \cdot \sqrt{\sin th}} \]
      7. distribute-rgt-neg-in16.4%

        \[\leadsto \color{blue}{\sqrt{\sin th} \cdot \left(-\sqrt{\sin th}\right)} \]
    8. Applied egg-rr16.4%

      \[\leadsto \color{blue}{\sqrt{\sin th} \cdot \left(-\sqrt{\sin th}\right)} \]
    9. Taylor expanded in th around 0 19.3%

      \[\leadsto \color{blue}{-1 \cdot th} \]
    10. Step-by-step derivation
      1. neg-mul-119.3%

        \[\leadsto \color{blue}{-th} \]
    11. Simplified19.3%

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

    if -5.8999999999999998e-238 < ky

    1. Initial program 94.5%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. +-commutative94.5%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
      2. unpow294.5%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
      3. unpow294.5%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      4. hypot-def99.8%

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

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

        \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}}} \]
      2. div-inv99.5%

        \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \frac{1}{\sin th}}} \]
      3. associate-/r*99.6%

        \[\leadsto \color{blue}{\frac{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}}{\frac{1}{\sin th}}} \]
    5. Applied egg-rr99.6%

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

      \[\leadsto \frac{\color{blue}{1}}{\frac{1}{\sin th}} \]
    7. Taylor expanded in th around 0 17.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq -5.9 \cdot 10^{-238}:\\ \;\;\;\;-th\\ \mathbf{else}:\\ \;\;\;\;th\\ \end{array} \]

Alternative 15: 13.9% accurate, 709.0× speedup?

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

\\
th
\end{array}
Derivation
  1. Initial program 95.9%

    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
  2. Step-by-step derivation
    1. +-commutative95.9%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]
    2. unpow295.9%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
    3. unpow295.9%

      \[\leadsto \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
    4. hypot-def99.7%

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

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

      \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}}} \]
    2. div-inv99.5%

      \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \frac{1}{\sin th}}} \]
    3. associate-/r*99.5%

      \[\leadsto \color{blue}{\frac{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}}{\frac{1}{\sin th}}} \]
  5. Applied egg-rr99.5%

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

    \[\leadsto \frac{\color{blue}{1}}{\frac{1}{\sin th}} \]
  7. Taylor expanded in th around 0 14.7%

    \[\leadsto \color{blue}{th} \]
  8. Final simplification14.7%

    \[\leadsto th \]

Reproduce

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