Toniolo and Linder, Equation (3b), real

Percentage Accurate: 93.8% → 99.7%
Time: 15.0s
Alternatives: 16
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 16 alternatives:

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

Initial Program: 93.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \frac{\sin ky}{\mathsf{hypot}\left(\sin 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 92.6%

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

      \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \color{blue}{\left(-\left(-\sin th\right)\right)} \]
    2. sin-neg92.6%

      \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \left(-\color{blue}{\sin \left(-th\right)}\right) \]
    3. neg-mul-192.6%

      \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \color{blue}{\left(-1 \cdot \sin \left(-th\right)\right)} \]
    4. *-commutative92.6%

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin \left(-th\right)}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot -1 \]
    7. associate-/r/89.4%

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

      \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{-1}} \cdot \sin \left(-th\right)} \]
    9. associate-/r/92.5%

      \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{-1}}{\sin \left(-th\right)}}} \]
    10. sin-neg92.5%

      \[\leadsto \frac{\sin ky}{\frac{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{-1}}{\color{blue}{-\sin th}}} \]
    11. neg-mul-192.5%

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

      \[\leadsto \frac{\sin ky}{\color{blue}{\frac{\frac{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{-1}}{-1}}{\sin th}}} \]
    13. associate-/r/92.6%

      \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{-1}}{-1}} \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: 76.1% accurate, 1.2× speedup?

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

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

\mathbf{elif}\;\sin ky \leq 6 \cdot 10^{-6}:\\
\;\;\;\;\frac{ky}{\frac{t_1}{\sin th}}\\

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sin ky}{\frac{1 \cdot \color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}}{th}} \]
      6. *-lft-identity40.8%

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

        \[\leadsto \frac{\sin ky}{\frac{\color{blue}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}}{th}} \]
      8. unpow240.8%

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

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

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

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

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

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

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

    if -0.0200000000000000004 < (sin.f64 ky) < 6.0000000000000002e-6

    1. Initial program 84.6%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th\right)\right)} \]
      2. expm1-udef26.8%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th\right)} - 1} \]
    3. Applied egg-rr33.3%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin th\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def99.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin th\right)\right)} \]
      2. expm1-log1p99.6%

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

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

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

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

        \[\leadsto \color{blue}{\frac{ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{\sin th}}} \]
      2. add-cube-cbrt97.8%

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

        \[\leadsto \frac{\left(\sqrt[3]{ky} \cdot \sqrt[3]{ky}\right) \cdot \sqrt[3]{ky}}{\color{blue}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \frac{1}{\sin th}}} \]
      4. times-frac96.4%

        \[\leadsto \color{blue}{\frac{\sqrt[3]{ky} \cdot \sqrt[3]{ky}}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}}} \]
      5. pow296.4%

        \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{ky}\right)}^{2}}}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}} \]
      6. hypot-udef81.9%

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2}}{\color{blue}{\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}}} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}} \]
      7. +-commutative81.9%

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2}}{\sqrt{\color{blue}{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}} \]
      8. hypot-udef96.4%

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2}}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}} \]
    8. Applied egg-rr96.4%

      \[\leadsto \color{blue}{\frac{{\left(\sqrt[3]{ky}\right)}^{2}}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}}} \]
    9. Step-by-step derivation
      1. times-frac97.7%

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

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2} \cdot \sqrt[3]{ky}}{\color{blue}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot 1}{\sin th}}} \]
      3. *-rgt-identity97.8%

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

        \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{ky} \cdot \sqrt[3]{ky}\right)} \cdot \sqrt[3]{ky}}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}} \]
      5. rem-3cbrt-lft99.2%

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

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

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

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

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

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

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

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

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

    if 6.0000000000000002e-6 < (sin.f64 ky)

    1. Initial program 99.8%

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

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

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

Alternative 3: 76.1% accurate, 1.2× speedup?

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

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

\mathbf{elif}\;\sin ky \leq 6 \cdot 10^{-6}:\\
\;\;\;\;\frac{ky}{\frac{t_1}{\sin th}}\\

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


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

    1. Initial program 99.7%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th\right)\right)} \]
      2. expm1-udef64.6%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th\right)} - 1} \]
    3. Applied egg-rr64.6%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin th\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def99.6%

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

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

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

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

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

    if -0.0200000000000000004 < (sin.f64 ky) < 6.0000000000000002e-6

    1. Initial program 84.6%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th\right)\right)} \]
      2. expm1-udef26.8%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th\right)} - 1} \]
    3. Applied egg-rr33.3%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin th\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def99.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin th\right)\right)} \]
      2. expm1-log1p99.6%

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

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

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

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

        \[\leadsto \color{blue}{\frac{ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{\sin th}}} \]
      2. add-cube-cbrt97.8%

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

        \[\leadsto \frac{\left(\sqrt[3]{ky} \cdot \sqrt[3]{ky}\right) \cdot \sqrt[3]{ky}}{\color{blue}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \frac{1}{\sin th}}} \]
      4. times-frac96.4%

        \[\leadsto \color{blue}{\frac{\sqrt[3]{ky} \cdot \sqrt[3]{ky}}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}}} \]
      5. pow296.4%

        \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{ky}\right)}^{2}}}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}} \]
      6. hypot-udef81.9%

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2}}{\color{blue}{\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}}} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}} \]
      7. +-commutative81.9%

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2}}{\sqrt{\color{blue}{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}} \]
      8. hypot-udef96.4%

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2}}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}} \]
    8. Applied egg-rr96.4%

      \[\leadsto \color{blue}{\frac{{\left(\sqrt[3]{ky}\right)}^{2}}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}}} \]
    9. Step-by-step derivation
      1. times-frac97.7%

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

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2} \cdot \sqrt[3]{ky}}{\color{blue}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot 1}{\sin th}}} \]
      3. *-rgt-identity97.8%

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

        \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{ky} \cdot \sqrt[3]{ky}\right)} \cdot \sqrt[3]{ky}}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}} \]
      5. rem-3cbrt-lft99.2%

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

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

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

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

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

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

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

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

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

    if 6.0000000000000002e-6 < (sin.f64 ky)

    1. Initial program 99.8%

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

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

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

Alternative 4: 76.2% accurate, 1.2× speedup?

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

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

\mathbf{elif}\;\sin ky \leq 6 \cdot 10^{-6}:\\
\;\;\;\;\frac{ky}{\frac{t_1}{\sin th}}\\

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin ky}{\color{blue}{0.16666666666666666 \cdot \left(th \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right) + \frac{1}{th} \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
    5. Step-by-step derivation
      1. +-commutative42.0%

        \[\leadsto \frac{\sin ky}{\color{blue}{\frac{1}{th} \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}} + 0.16666666666666666 \cdot \left(th \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}} \]
      2. +-commutative42.0%

        \[\leadsto \frac{\sin ky}{\frac{1}{th} \cdot \sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}} + 0.16666666666666666 \cdot \left(th \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
      3. unpow242.0%

        \[\leadsto \frac{\sin ky}{\frac{1}{th} \cdot \sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}} + 0.16666666666666666 \cdot \left(th \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
      4. unpow242.0%

        \[\leadsto \frac{\sin ky}{\frac{1}{th} \cdot \sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}} + 0.16666666666666666 \cdot \left(th \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
      5. hypot-def42.0%

        \[\leadsto \frac{\sin ky}{\frac{1}{th} \cdot \color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} + 0.16666666666666666 \cdot \left(th \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
      6. associate-*r*42.0%

        \[\leadsto \frac{\sin ky}{\frac{1}{th} \cdot \mathsf{hypot}\left(\sin ky, \sin kx\right) + \color{blue}{\left(0.16666666666666666 \cdot th\right) \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
      7. +-commutative42.0%

        \[\leadsto \frac{\sin ky}{\frac{1}{th} \cdot \mathsf{hypot}\left(\sin ky, \sin kx\right) + \left(0.16666666666666666 \cdot th\right) \cdot \sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \]
      8. unpow242.0%

        \[\leadsto \frac{\sin ky}{\frac{1}{th} \cdot \mathsf{hypot}\left(\sin ky, \sin kx\right) + \left(0.16666666666666666 \cdot th\right) \cdot \sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \]
      9. unpow242.0%

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

        \[\leadsto \frac{\sin ky}{\frac{1}{th} \cdot \mathsf{hypot}\left(\sin ky, \sin kx\right) + \left(0.16666666666666666 \cdot th\right) \cdot \color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
      11. distribute-rgt-out42.0%

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

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

    if -0.0200000000000000004 < (sin.f64 ky) < 6.0000000000000002e-6

    1. Initial program 84.6%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th\right)\right)} \]
      2. expm1-udef26.8%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th\right)} - 1} \]
    3. Applied egg-rr33.3%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin th\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def99.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin th\right)\right)} \]
      2. expm1-log1p99.6%

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

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

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

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

        \[\leadsto \color{blue}{\frac{ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{\sin th}}} \]
      2. add-cube-cbrt97.8%

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

        \[\leadsto \frac{\left(\sqrt[3]{ky} \cdot \sqrt[3]{ky}\right) \cdot \sqrt[3]{ky}}{\color{blue}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \frac{1}{\sin th}}} \]
      4. times-frac96.4%

        \[\leadsto \color{blue}{\frac{\sqrt[3]{ky} \cdot \sqrt[3]{ky}}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}}} \]
      5. pow296.4%

        \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{ky}\right)}^{2}}}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}} \]
      6. hypot-udef81.9%

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2}}{\color{blue}{\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}}} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}} \]
      7. +-commutative81.9%

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2}}{\sqrt{\color{blue}{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}} \]
      8. hypot-udef96.4%

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2}}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}} \]
    8. Applied egg-rr96.4%

      \[\leadsto \color{blue}{\frac{{\left(\sqrt[3]{ky}\right)}^{2}}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}}} \]
    9. Step-by-step derivation
      1. times-frac97.7%

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

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2} \cdot \sqrt[3]{ky}}{\color{blue}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot 1}{\sin th}}} \]
      3. *-rgt-identity97.8%

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

        \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{ky} \cdot \sqrt[3]{ky}\right)} \cdot \sqrt[3]{ky}}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}} \]
      5. rem-3cbrt-lft99.2%

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

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

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

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

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

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

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

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

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

    if 6.0000000000000002e-6 < (sin.f64 ky)

    1. Initial program 99.8%

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

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

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

Alternative 5: 99.6% accurate, 1.4× speedup?

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

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

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

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th\right)\right)} \]
    2. expm1-udef43.5%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th\right)} - 1} \]
  3. Applied egg-rr46.6%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin th\right)} - 1} \]
  4. Step-by-step derivation
    1. expm1-def99.5%

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

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

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

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

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

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

      \[\leadsto \sin ky \cdot \frac{\sin th}{\color{blue}{\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}}} \]
    8. unpow292.6%

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

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

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

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

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

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

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

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

Alternative 6: 57.3% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;ky \leq 7.5 \cdot 10^{-6}:\\
\;\;\;\;\frac{ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{\sin th}}\\

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


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

    1. Initial program 89.9%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th\right)\right)} \]
      2. expm1-udef36.9%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th\right)} - 1} \]
    3. Applied egg-rr41.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin th\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def99.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin th\right)\right)} \]
      2. expm1-log1p99.6%

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

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

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

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

        \[\leadsto \color{blue}{\frac{ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{\sin th}}} \]
      2. add-cube-cbrt64.9%

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

        \[\leadsto \frac{\left(\sqrt[3]{ky} \cdot \sqrt[3]{ky}\right) \cdot \sqrt[3]{ky}}{\color{blue}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \frac{1}{\sin th}}} \]
      4. times-frac64.0%

        \[\leadsto \color{blue}{\frac{\sqrt[3]{ky} \cdot \sqrt[3]{ky}}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}}} \]
      5. pow264.0%

        \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{ky}\right)}^{2}}}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}} \]
      6. hypot-udef54.5%

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2}}{\color{blue}{\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}}} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}} \]
      7. +-commutative54.5%

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2}}{\sqrt{\color{blue}{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}} \]
      8. hypot-udef64.0%

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2}}{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}} \]
    8. Applied egg-rr64.0%

      \[\leadsto \color{blue}{\frac{{\left(\sqrt[3]{ky}\right)}^{2}}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \frac{\sqrt[3]{ky}}{\frac{1}{\sin th}}} \]
    9. Step-by-step derivation
      1. times-frac64.8%

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

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2} \cdot \sqrt[3]{ky}}{\color{blue}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot 1}{\sin th}}} \]
      3. *-rgt-identity64.9%

        \[\leadsto \frac{{\left(\sqrt[3]{ky}\right)}^{2} \cdot \sqrt[3]{ky}}{\frac{\color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}}{\sin th}} \]
      4. unpow264.9%

        \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{ky} \cdot \sqrt[3]{ky}\right)} \cdot \sqrt[3]{ky}}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}} \]
      5. rem-3cbrt-lft65.8%

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

        \[\leadsto \frac{ky}{\frac{\color{blue}{\sqrt{\sin ky \cdot \sin ky + \sin kx \cdot \sin kx}}}{\sin th}} \]
      7. unpow256.1%

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

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

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

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

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

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

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

    if 7.50000000000000019e-6 < ky

    1. Initial program 99.8%

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

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

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

Alternative 7: 30.3% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;kx \leq 5.6 \cdot 10^{-30}:\\
\;\;\;\;\sin th\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if kx < 5.59999999999999977e-30

    1. Initial program 90.3%

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

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

    if 5.59999999999999977e-30 < kx

    1. Initial program 99.6%

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

      \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
    3. Step-by-step derivation
      1. add-sqr-sqrt17.2%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{\sin ky}{\sin kx}} \cdot \sqrt{\frac{\sin ky}{\sin kx}}\right)} \cdot \sin th \]
      2. sqrt-unprod28.4%

        \[\leadsto \color{blue}{\sqrt{\frac{\sin ky}{\sin kx} \cdot \frac{\sin ky}{\sin kx}}} \cdot \sin th \]
      3. pow228.4%

        \[\leadsto \sqrt{\color{blue}{{\left(\frac{\sin ky}{\sin kx}\right)}^{2}}} \cdot \sin th \]
    4. Applied egg-rr28.4%

      \[\leadsto \color{blue}{\sqrt{{\left(\frac{\sin ky}{\sin kx}\right)}^{2}}} \cdot \sin th \]
    5. Step-by-step derivation
      1. unpow228.4%

        \[\leadsto \sqrt{\color{blue}{\frac{\sin ky}{\sin kx} \cdot \frac{\sin ky}{\sin kx}}} \cdot \sin th \]
      2. rem-sqrt-square31.1%

        \[\leadsto \color{blue}{\left|\frac{\sin ky}{\sin kx}\right|} \cdot \sin th \]
    6. Simplified31.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 5.6 \cdot 10^{-30}:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\ \end{array} \]

Alternative 8: 31.1% accurate, 2.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;ky \leq 8.8 \cdot 10^{-69}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\

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


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

    1. Initial program 89.3%

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

      \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
    3. Step-by-step derivation
      1. add-sqr-sqrt13.6%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{\sin ky}{\sin kx}} \cdot \sqrt{\frac{\sin ky}{\sin kx}}\right)} \cdot \sin th \]
      2. sqrt-unprod23.4%

        \[\leadsto \color{blue}{\sqrt{\frac{\sin ky}{\sin kx} \cdot \frac{\sin ky}{\sin kx}}} \cdot \sin th \]
      3. pow223.4%

        \[\leadsto \sqrt{\color{blue}{{\left(\frac{\sin ky}{\sin kx}\right)}^{2}}} \cdot \sin th \]
    4. Applied egg-rr23.4%

      \[\leadsto \color{blue}{\sqrt{{\left(\frac{\sin ky}{\sin kx}\right)}^{2}}} \cdot \sin th \]
    5. Step-by-step derivation
      1. unpow223.4%

        \[\leadsto \sqrt{\color{blue}{\frac{\sin ky}{\sin kx} \cdot \frac{\sin ky}{\sin kx}}} \cdot \sin th \]
      2. rem-sqrt-square27.2%

        \[\leadsto \color{blue}{\left|\frac{\sin ky}{\sin kx}\right|} \cdot \sin th \]
    6. Simplified27.2%

      \[\leadsto \color{blue}{\left|\frac{\sin ky}{\sin kx}\right|} \cdot \sin th \]
    7. Taylor expanded in ky around 0 25.6%

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

    if 8.8000000000000001e-69 < ky

    1. Initial program 99.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 8.8 \cdot 10^{-69}:\\ \;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]

Alternative 9: 32.5% accurate, 3.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;ky \leq 3.6 \cdot 10^{-69}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\

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


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

    1. Initial program 89.3%

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

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

        \[\leadsto \color{blue}{\frac{ky}{\frac{\sin kx}{\sin th}}} \]
      2. associate-/r/33.7%

        \[\leadsto \color{blue}{\frac{ky}{\sin kx} \cdot \sin th} \]
    4. Simplified33.7%

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

    if 3.60000000000000018e-69 < ky

    1. Initial program 99.8%

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

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

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

Alternative 10: 32.6% accurate, 3.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;ky \leq 8.2 \cdot 10^{-69}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{\sin th}}\\

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


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

    1. Initial program 89.3%

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

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

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

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

    if 8.1999999999999998e-69 < ky

    1. Initial program 99.8%

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

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

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

Alternative 11: 32.5% accurate, 3.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;ky \leq 2.1 \cdot 10^{-69}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\

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


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

    1. Initial program 89.3%

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

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

        \[\leadsto \sin th \cdot \color{blue}{\frac{1}{\frac{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}{\sin ky}}} \]
      3. un-div-inv89.4%

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

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

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

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

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

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

    if 2.1e-69 < ky

    1. Initial program 99.8%

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

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

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

Alternative 12: 26.5% accurate, 6.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;ky \leq 2.2 \cdot 10^{-129}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\

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


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

    1. Initial program 88.9%

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

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

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

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

    if 2.20000000000000003e-129 < ky

    1. Initial program 99.8%

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

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

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

Alternative 13: 26.5% accurate, 6.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;ky \leq 7 \cdot 10^{-129}:\\
\;\;\;\;\frac{ky}{\frac{kx}{\sin th}}\\

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


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

    1. Initial program 88.9%

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

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

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

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

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

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

    if 6.9999999999999995e-129 < ky

    1. Initial program 99.8%

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

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

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

Alternative 14: 22.6% accurate, 6.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;ky \leq 10^{-192}:\\
\;\;\;\;\frac{ky \cdot th}{kx}\\

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


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

    1. Initial program 89.4%

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

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

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

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

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

    if 1.0000000000000001e-192 < ky

    1. Initial program 98.0%

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

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

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

Alternative 15: 17.3% accurate, 64.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq 1.9 \cdot 10^{-165}:\\ \;\;\;\;\frac{ky \cdot th}{kx}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{th} + th \cdot 0.16666666666666666}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= ky 1.9e-165)
   (/ (* ky th) kx)
   (/ 1.0 (+ (/ 1.0 th) (* th 0.16666666666666666)))))
double code(double kx, double ky, double th) {
	double tmp;
	if (ky <= 1.9e-165) {
		tmp = (ky * th) / kx;
	} 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 <= 1.9d-165) then
        tmp = (ky * th) / kx
    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 <= 1.9e-165) {
		tmp = (ky * th) / kx;
	} else {
		tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
	}
	return tmp;
}
def code(kx, ky, th):
	tmp = 0
	if ky <= 1.9e-165:
		tmp = (ky * th) / kx
	else:
		tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666))
	return tmp
function code(kx, ky, th)
	tmp = 0.0
	if (ky <= 1.9e-165)
		tmp = Float64(Float64(ky * th) / kx);
	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 <= 1.9e-165)
		tmp = (ky * th) / kx;
	else
		tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := If[LessEqual[ky, 1.9e-165], N[(N[(ky * th), $MachinePrecision] / kx), $MachinePrecision], 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 1.9 \cdot 10^{-165}:\\
\;\;\;\;\frac{ky \cdot th}{kx}\\

\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 < 1.90000000000000009e-165

    1. Initial program 89.5%

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

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

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

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

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

    if 1.90000000000000009e-165 < ky

    1. Initial program 97.9%

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin ky}{\color{blue}{0.16666666666666666 \cdot \left(th \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right) + \frac{1}{th} \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
    5. Step-by-step derivation
      1. +-commutative46.7%

        \[\leadsto \frac{\sin ky}{\color{blue}{\frac{1}{th} \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}} + 0.16666666666666666 \cdot \left(th \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)}} \]
      2. +-commutative46.7%

        \[\leadsto \frac{\sin ky}{\frac{1}{th} \cdot \sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}} + 0.16666666666666666 \cdot \left(th \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
      3. unpow246.7%

        \[\leadsto \frac{\sin ky}{\frac{1}{th} \cdot \sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}} + 0.16666666666666666 \cdot \left(th \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
      4. unpow246.7%

        \[\leadsto \frac{\sin ky}{\frac{1}{th} \cdot \sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}} + 0.16666666666666666 \cdot \left(th \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
      5. hypot-def48.5%

        \[\leadsto \frac{\sin ky}{\frac{1}{th} \cdot \color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} + 0.16666666666666666 \cdot \left(th \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}\right)} \]
      6. associate-*r*48.5%

        \[\leadsto \frac{\sin ky}{\frac{1}{th} \cdot \mathsf{hypot}\left(\sin ky, \sin kx\right) + \color{blue}{\left(0.16666666666666666 \cdot th\right) \cdot \sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
      7. +-commutative48.5%

        \[\leadsto \frac{\sin ky}{\frac{1}{th} \cdot \mathsf{hypot}\left(\sin ky, \sin kx\right) + \left(0.16666666666666666 \cdot th\right) \cdot \sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \]
      8. unpow248.5%

        \[\leadsto \frac{\sin ky}{\frac{1}{th} \cdot \mathsf{hypot}\left(\sin ky, \sin kx\right) + \left(0.16666666666666666 \cdot th\right) \cdot \sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \]
      9. unpow248.5%

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

        \[\leadsto \frac{\sin ky}{\frac{1}{th} \cdot \mathsf{hypot}\left(\sin ky, \sin kx\right) + \left(0.16666666666666666 \cdot th\right) \cdot \color{blue}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
      11. distribute-rgt-out48.5%

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

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

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

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

Alternative 16: 12.5% accurate, 141.8× speedup?

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

\\
\frac{ky \cdot th}{kx}
\end{array}
Derivation
  1. Initial program 92.6%

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

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

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

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

    \[\leadsto \color{blue}{\frac{ky \cdot th}{kx}} \]
  6. Final simplification12.6%

    \[\leadsto \frac{ky \cdot th}{kx} \]

Reproduce

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