Toniolo and Linder, Equation (3b), real

Percentage Accurate: 94.0% → 99.6%
Time: 24.1s
Alternatives: 19
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 19 alternatives:

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

Initial Program: 94.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.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.2%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 76.2% accurate, 1.0× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;t_1\\


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin ky}\right)} - 1 \]
      4. *-commutative50.0%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}}\right)} - 1 \]
    5. Applied egg-rr50.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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}}}} \]
    9. Step-by-step derivation
      1. +-commutative53.9%

        \[\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. +-commutative53.9%

        \[\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. unpow253.9%

        \[\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. unpow253.9%

        \[\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-def53.9%

        \[\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*53.9%

        \[\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. +-commutative53.9%

        \[\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. unpow253.9%

        \[\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. unpow253.9%

        \[\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-def53.9%

        \[\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-out53.9%

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

      \[\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) < 1.2e-14

    1. Initial program 90.7%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\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. Step-by-step derivation
      1. clear-num99.6%

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

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

      \[\leadsto \frac{\sin th}{\color{blue}{{\left(\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\right)}^{-1}}} \]
    6. Step-by-step derivation
      1. unpow-199.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.2e-14 < (sin.f64 ky) < 0.910000000000000031

    1. Initial program 99.7%

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

      \[\leadsto \color{blue}{\sin th} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification78.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 1.2 \cdot 10^{-14}:\\ \;\;\;\;\frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right) \cdot \frac{1}{ky}}\\ \mathbf{elif}\;\sin ky \leq 0.91:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right) \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\ \end{array} \]

Alternative 3: 61.4% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;\sin th \leq -0.04:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\

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

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


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

    1. Initial program 93.4%

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

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

    if -0.80000000000000004 < (sin.f64 th) < -0.0400000000000000008

    1. Initial program 96.5%

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

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

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

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

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

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

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

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

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

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

    if -0.0400000000000000008 < (sin.f64 th) < 0.050000000000000003

    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/89.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(e^{\mathsf{log1p}\left(th \cdot \frac{1}{\sqrt{\sin kx \cdot \sin kx + \color{blue}{\sin ky \cdot \sin ky}}}\right)} - 1\right) \cdot \sin ky \]
      8. hypot-udef27.8%

        \[\leadsto \left(e^{\mathsf{log1p}\left(th \cdot \frac{1}{\color{blue}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}}\right)} - 1\right) \cdot \sin ky \]
      9. un-div-inv27.8%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}}\right)} - 1\right) \cdot \sin ky \]
    8. Applied egg-rr27.8%

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

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

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

        \[\leadsto \frac{th}{\color{blue}{\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}}} \cdot \sin ky \]
      4. unpow294.0%

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

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

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

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

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

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

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

    if 0.050000000000000003 < (sin.f64 th)

    1. Initial program 93.1%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 61.4% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;\sin th \leq -0.04:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\

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

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


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

    1. Initial program 93.4%

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

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

    if -0.80000000000000004 < (sin.f64 th) < -0.0400000000000000008

    1. Initial program 96.5%

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

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

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

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

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

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

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

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

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

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

    if -0.0400000000000000008 < (sin.f64 th) < 0.050000000000000003

    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 \color{blue}{\sin th \cdot \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
      2. clear-num95.8%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\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. Step-by-step derivation
      1. expm1-log1p-u99.7%

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin ky}\right)} - 1 \]
      4. *-commutative21.3%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}}\right)} - 1 \]
    5. Applied egg-rr21.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.050000000000000003 < (sin.f64 th)

    1. Initial program 93.1%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 76.1% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(th \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{1}}{\sqrt{{\sin ky}^{2} + {\sin kx}^{2}}}}\right)} - 1\right)\right) \cdot \sin ky \]
      4. metadata-eval47.7%

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

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

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

        \[\leadsto \left(th \cdot \left(e^{\mathsf{log1p}\left(\frac{1}{\sqrt{\sin kx \cdot \sin kx + \color{blue}{\sin ky \cdot \sin ky}}}\right)} - 1\right)\right) \cdot \sin ky \]
      8. hypot-udef47.7%

        \[\leadsto \left(th \cdot \left(e^{\mathsf{log1p}\left(\frac{1}{\color{blue}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}}\right)} - 1\right)\right) \cdot \sin ky \]
    8. Applied egg-rr47.7%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(th \cdot \color{blue}{\frac{1}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}}\right) \cdot \sin ky \]
    11. Step-by-step derivation
      1. expm1-log1p-u47.2%

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{th \cdot \left(\frac{1}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin ky\right)}\right)} - 1 \]
      4. associate-*l/3.9%

        \[\leadsto e^{\mathsf{log1p}\left(th \cdot \color{blue}{\frac{1 \cdot \sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}}\right)} - 1 \]
      5. *-un-lft-identity3.9%

        \[\leadsto e^{\mathsf{log1p}\left(th \cdot \frac{\color{blue}{\sin ky}}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\right)} - 1 \]
    12. Applied egg-rr3.9%

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

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

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

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

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

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

    if -0.0200000000000000004 < (sin.f64 ky) < 1.2e-14

    1. Initial program 90.7%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\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. Step-by-step derivation
      1. clear-num99.6%

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

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

      \[\leadsto \frac{\sin th}{\color{blue}{{\left(\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\right)}^{-1}}} \]
    6. Step-by-step derivation
      1. unpow-199.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.2e-14 < (sin.f64 ky) < 0.910000000000000031

    1. Initial program 99.7%

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

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

    if 0.910000000000000031 < (sin.f64 ky)

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin ky}\right)} - 1 \]
      4. *-commutative25.3%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}}\right)} - 1 \]
    5. Applied egg-rr25.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 45.0% accurate, 1.2× speedup?

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

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

\mathbf{elif}\;\sin ky \leq 10^{-70}:\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\

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


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

    1. Initial program 94.8%

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

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

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

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

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

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

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

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

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

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

    if 1e-263 < (sin.f64 ky) < 9.99999999999999996e-71

    1. Initial program 88.7%

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

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

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

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

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

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

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

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

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

    if 9.99999999999999996e-71 < (sin.f64 ky)

    1. Initial program 99.6%

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

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

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

Alternative 7: 99.7% accurate, 1.4× speedup?

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

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

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

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

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]
    3. unpow295.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. Final simplification99.6%

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

Alternative 8: 40.3% accurate, 1.7× speedup?

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

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

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


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

    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 36.2%

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

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

    1. Initial program 99.6%

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

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

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

Alternative 9: 40.3% accurate, 1.7× speedup?

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

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

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


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

    1. Initial program 92.6%

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 99.6%

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

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

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

Alternative 10: 33.3% accurate, 2.3× speedup?

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

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

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


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

    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 36.6%

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

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

        \[\leadsto \color{blue}{\frac{\sin ky}{\frac{kx}{\sin th}}} \]
    5. Simplified27.5%

      \[\leadsto \color{blue}{\frac{\sin ky}{\frac{kx}{\sin th}}} \]
    6. Taylor expanded in ky around inf 24.1%

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

        \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{kx}} \]
    8. Simplified27.5%

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

    if 1.99999999999999996e-137 < (sin.f64 ky)

    1. Initial program 99.6%

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

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

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

Alternative 11: 39.0% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq 2 \cdot 10^{-138}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= (sin ky) 2e-138) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
	double tmp;
	if (sin(ky) <= 2e-138) {
		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) <= 2d-138) 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) <= 2e-138) {
		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) <= 2e-138:
		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) <= 2e-138)
		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) <= 2e-138)
		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], 2e-138], 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 2 \cdot 10^{-138}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\

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


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

    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 31.0%

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

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

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

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

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

    1. Initial program 99.6%

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

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

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

Alternative 12: 39.1% accurate, 2.3× speedup?

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

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


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

    1. Initial program 92.6%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\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 31.0%

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

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

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

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

    1. Initial program 99.6%

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

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

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

Alternative 13: 33.1% accurate, 3.4× speedup?

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

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

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


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

    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 36.6%

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

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

        \[\leadsto \color{blue}{\frac{\sin ky}{\frac{kx}{\sin th}}} \]
    5. Simplified27.5%

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

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

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

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

    if 1.99999999999999996e-137 < (sin.f64 ky)

    1. Initial program 99.6%

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

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

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

Alternative 14: 31.4% accurate, 6.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq -116 \lor \neg \left(ky \leq 1.45 \cdot 10^{-138}\right):\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;th \cdot \frac{ky}{\sin kx}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (or (<= ky -116.0) (not (<= ky 1.45e-138)))
   (sin th)
   (* th (/ ky (sin kx)))))
double code(double kx, double ky, double th) {
	double tmp;
	if ((ky <= -116.0) || !(ky <= 1.45e-138)) {
		tmp = sin(th);
	} else {
		tmp = th * (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 ((ky <= (-116.0d0)) .or. (.not. (ky <= 1.45d-138))) then
        tmp = sin(th)
    else
        tmp = th * (ky / sin(kx))
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double tmp;
	if ((ky <= -116.0) || !(ky <= 1.45e-138)) {
		tmp = Math.sin(th);
	} else {
		tmp = th * (ky / Math.sin(kx));
	}
	return tmp;
}
def code(kx, ky, th):
	tmp = 0
	if (ky <= -116.0) or not (ky <= 1.45e-138):
		tmp = math.sin(th)
	else:
		tmp = th * (ky / math.sin(kx))
	return tmp
function code(kx, ky, th)
	tmp = 0.0
	if ((ky <= -116.0) || !(ky <= 1.45e-138))
		tmp = sin(th);
	else
		tmp = Float64(th * Float64(ky / sin(kx)));
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	tmp = 0.0;
	if ((ky <= -116.0) || ~((ky <= 1.45e-138)))
		tmp = sin(th);
	else
		tmp = th * (ky / sin(kx));
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := If[Or[LessEqual[ky, -116.0], N[Not[LessEqual[ky, 1.45e-138]], $MachinePrecision]], N[Sin[th], $MachinePrecision], N[(th * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;ky \leq -116 \lor \neg \left(ky \leq 1.45 \cdot 10^{-138}\right):\\
\;\;\;\;\sin th\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < -116 or 1.44999999999999987e-138 < ky

    1. Initial program 99.6%

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

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

    if -116 < ky < 1.44999999999999987e-138

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{ky}{\frac{\sin kx}{th}}} \]
    10. Step-by-step derivation
      1. associate-/r/44.2%

        \[\leadsto \color{blue}{\frac{ky}{\sin kx} \cdot th} \]
    11. Applied egg-rr44.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq -116 \lor \neg \left(ky \leq 1.45 \cdot 10^{-138}\right):\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;th \cdot \frac{ky}{\sin kx}\\ \end{array} \]

Alternative 15: 30.0% accurate, 6.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq -116 \lor \neg \left(ky \leq 5.5 \cdot 10^{-139}\right):\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;th \cdot \frac{ky}{kx}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (or (<= ky -116.0) (not (<= ky 5.5e-139))) (sin th) (* th (/ ky kx))))
double code(double kx, double ky, double th) {
	double tmp;
	if ((ky <= -116.0) || !(ky <= 5.5e-139)) {
		tmp = sin(th);
	} else {
		tmp = th * (ky / 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 ((ky <= (-116.0d0)) .or. (.not. (ky <= 5.5d-139))) then
        tmp = sin(th)
    else
        tmp = th * (ky / kx)
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double tmp;
	if ((ky <= -116.0) || !(ky <= 5.5e-139)) {
		tmp = Math.sin(th);
	} else {
		tmp = th * (ky / kx);
	}
	return tmp;
}
def code(kx, ky, th):
	tmp = 0
	if (ky <= -116.0) or not (ky <= 5.5e-139):
		tmp = math.sin(th)
	else:
		tmp = th * (ky / kx)
	return tmp
function code(kx, ky, th)
	tmp = 0.0
	if ((ky <= -116.0) || !(ky <= 5.5e-139))
		tmp = sin(th);
	else
		tmp = Float64(th * Float64(ky / kx));
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	tmp = 0.0;
	if ((ky <= -116.0) || ~((ky <= 5.5e-139)))
		tmp = sin(th);
	else
		tmp = th * (ky / kx);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := If[Or[LessEqual[ky, -116.0], N[Not[LessEqual[ky, 5.5e-139]], $MachinePrecision]], N[Sin[th], $MachinePrecision], N[(th * N[(ky / kx), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;ky \leq -116 \lor \neg \left(ky \leq 5.5 \cdot 10^{-139}\right):\\
\;\;\;\;\sin th\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < -116 or 5.4999999999999997e-139 < ky

    1. Initial program 99.6%

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

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

    if -116 < ky < 5.4999999999999997e-139

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{ky}{\frac{kx}{th}}} \]
    12. Simplified36.3%

      \[\leadsto \color{blue}{\frac{ky}{\frac{kx}{th}}} \]
    13. Step-by-step derivation
      1. associate-/r/36.3%

        \[\leadsto \color{blue}{\frac{ky}{kx} \cdot th} \]
    14. Applied egg-rr36.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq -116 \lor \neg \left(ky \leq 5.5 \cdot 10^{-139}\right):\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;th \cdot \frac{ky}{kx}\\ \end{array} \]

Alternative 16: 21.6% accurate, 54.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq -390 \lor \neg \left(ky \leq 1.3 \cdot 10^{-138}\right):\\ \;\;\;\;\frac{1}{\frac{1}{th} + th \cdot 0.16666666666666666}\\ \mathbf{else}:\\ \;\;\;\;th \cdot \frac{ky}{kx}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (or (<= ky -390.0) (not (<= ky 1.3e-138)))
   (/ 1.0 (+ (/ 1.0 th) (* th 0.16666666666666666)))
   (* th (/ ky kx))))
double code(double kx, double ky, double th) {
	double tmp;
	if ((ky <= -390.0) || !(ky <= 1.3e-138)) {
		tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
	} else {
		tmp = th * (ky / 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 ((ky <= (-390.0d0)) .or. (.not. (ky <= 1.3d-138))) then
        tmp = 1.0d0 / ((1.0d0 / th) + (th * 0.16666666666666666d0))
    else
        tmp = th * (ky / kx)
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double tmp;
	if ((ky <= -390.0) || !(ky <= 1.3e-138)) {
		tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
	} else {
		tmp = th * (ky / kx);
	}
	return tmp;
}
def code(kx, ky, th):
	tmp = 0
	if (ky <= -390.0) or not (ky <= 1.3e-138):
		tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666))
	else:
		tmp = th * (ky / kx)
	return tmp
function code(kx, ky, th)
	tmp = 0.0
	if ((ky <= -390.0) || !(ky <= 1.3e-138))
		tmp = Float64(1.0 / Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)));
	else
		tmp = Float64(th * Float64(ky / kx));
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	tmp = 0.0;
	if ((ky <= -390.0) || ~((ky <= 1.3e-138)))
		tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
	else
		tmp = th * (ky / kx);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := If[Or[LessEqual[ky, -390.0], N[Not[LessEqual[ky, 1.3e-138]], $MachinePrecision]], N[(1.0 / N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(th * N[(ky / kx), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;ky \leq -390 \lor \neg \left(ky \leq 1.3 \cdot 10^{-138}\right):\\
\;\;\;\;\frac{1}{\frac{1}{th} + th \cdot 0.16666666666666666}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < -390 or 1.3e-138 < ky

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin ky}\right)} - 1 \]
      4. *-commutative43.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}}} \]
    8. Taylor expanded in th around 0 55.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}}}} \]
    9. Step-by-step derivation
      1. +-commutative55.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. +-commutative55.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. unpow255.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. unpow255.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-def55.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*55.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. +-commutative55.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. unpow255.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. unpow255.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-def55.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-out55.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)}} \]
    10. Simplified55.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)}} \]
    11. Taylor expanded in kx around 0 20.8%

      \[\leadsto \color{blue}{\frac{1}{0.16666666666666666 \cdot th + \frac{1}{th}}} \]

    if -390 < ky < 1.3e-138

    1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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}}} \]
    10. Taylor expanded in kx around 0 30.6%

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

        \[\leadsto \color{blue}{\frac{ky}{\frac{kx}{th}}} \]
    12. Simplified36.0%

      \[\leadsto \color{blue}{\frac{ky}{\frac{kx}{th}}} \]
    13. Step-by-step derivation
      1. associate-/r/36.0%

        \[\leadsto \color{blue}{\frac{ky}{kx} \cdot th} \]
    14. Applied egg-rr36.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq -390 \lor \neg \left(ky \leq 1.3 \cdot 10^{-138}\right):\\ \;\;\;\;\frac{1}{\frac{1}{th} + th \cdot 0.16666666666666666}\\ \mathbf{else}:\\ \;\;\;\;th \cdot \frac{ky}{kx}\\ \end{array} \]

Alternative 17: 21.3% accurate, 77.7× speedup?

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

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

\mathbf{elif}\;ky \leq 3.3 \cdot 10^{-137}:\\
\;\;\;\;ky \cdot \frac{th}{kx}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < -27500 or 3.3000000000000002e-137 < ky

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -27500 < ky < 3.3000000000000002e-137

    1. Initial program 88.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{ky}{\frac{kx}{th}}} \]
    12. Simplified35.3%

      \[\leadsto \color{blue}{\frac{ky}{\frac{kx}{th}}} \]
    13. Taylor expanded in ky around 0 30.1%

      \[\leadsto \color{blue}{\frac{ky \cdot th}{kx}} \]
    14. Step-by-step derivation
      1. associate-*r/35.3%

        \[\leadsto \color{blue}{ky \cdot \frac{th}{kx}} \]
    15. Simplified35.3%

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

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

Alternative 18: 21.3% accurate, 77.7× speedup?

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

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

\mathbf{elif}\;ky \leq 3.6 \cdot 10^{-137}:\\
\;\;\;\;th \cdot \frac{ky}{kx}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < -7200 or 3.60000000000000006e-137 < ky

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7200 < ky < 3.60000000000000006e-137

    1. Initial program 88.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{ky}{\frac{kx}{th}}} \]
    12. Simplified35.3%

      \[\leadsto \color{blue}{\frac{ky}{\frac{kx}{th}}} \]
    13. Step-by-step derivation
      1. associate-/r/35.3%

        \[\leadsto \color{blue}{\frac{ky}{kx} \cdot th} \]
    14. Applied egg-rr35.3%

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

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

Alternative 19: 13.6% 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.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto th \]

Reproduce

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