Toniolo and Linder, Equation (3b), real

Percentage Accurate: 94.5% → 99.7%
Time: 13.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.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 52.0% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ \mathbf{if}\;t\_1 \leq -0.1:\\ \;\;\;\;\sqrt{{\sin th}^{2}}\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-190}:\\ \;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\ \mathbf{elif}\;t\_1 \leq 0.002:\\ \;\;\;\;\left|\sin th \cdot \frac{ky}{\sin kx}\right|\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
   (if (<= t_1 -0.1)
     (sqrt (pow (sin th) 2.0))
     (if (<= t_1 2e-190)
       (/ (sin th) (/ (sin kx) ky))
       (if (<= t_1 0.002) (fabs (* (sin th) (/ ky (sin kx)))) (sin th))))))
double code(double kx, double ky, double th) {
	double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
	double tmp;
	if (t_1 <= -0.1) {
		tmp = sqrt(pow(sin(th), 2.0));
	} else if (t_1 <= 2e-190) {
		tmp = sin(th) / (sin(kx) / ky);
	} else if (t_1 <= 0.002) {
		tmp = fabs((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) :: t_1
    real(8) :: tmp
    t_1 = sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))
    if (t_1 <= (-0.1d0)) then
        tmp = sqrt((sin(th) ** 2.0d0))
    else if (t_1 <= 2d-190) then
        tmp = sin(th) / (sin(kx) / ky)
    else if (t_1 <= 0.002d0) then
        tmp = abs((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 t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)));
	double tmp;
	if (t_1 <= -0.1) {
		tmp = Math.sqrt(Math.pow(Math.sin(th), 2.0));
	} else if (t_1 <= 2e-190) {
		tmp = Math.sin(th) / (Math.sin(kx) / ky);
	} else if (t_1 <= 0.002) {
		tmp = Math.abs((Math.sin(th) * (ky / Math.sin(kx))));
	} else {
		tmp = Math.sin(th);
	}
	return tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))
	tmp = 0
	if t_1 <= -0.1:
		tmp = math.sqrt(math.pow(math.sin(th), 2.0))
	elif t_1 <= 2e-190:
		tmp = math.sin(th) / (math.sin(kx) / ky)
	elif t_1 <= 0.002:
		tmp = math.fabs((math.sin(th) * (ky / math.sin(kx))))
	else:
		tmp = math.sin(th)
	return tmp
function code(kx, ky, th)
	t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))
	tmp = 0.0
	if (t_1 <= -0.1)
		tmp = sqrt((sin(th) ^ 2.0));
	elseif (t_1 <= 2e-190)
		tmp = Float64(sin(th) / Float64(sin(kx) / ky));
	elseif (t_1 <= 0.002)
		tmp = abs(Float64(sin(th) * Float64(ky / sin(kx))));
	else
		tmp = sin(th);
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)));
	tmp = 0.0;
	if (t_1 <= -0.1)
		tmp = sqrt((sin(th) ^ 2.0));
	elseif (t_1 <= 2e-190)
		tmp = sin(th) / (sin(kx) / ky);
	elseif (t_1 <= 0.002)
		tmp = abs((sin(th) * (ky / sin(kx))));
	else
		tmp = sin(th);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, -0.1], N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 2e-190], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.002], N[Abs[N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_1 \leq -0.1:\\
\;\;\;\;\sqrt{{\sin th}^{2}}\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-190}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\

\mathbf{elif}\;t\_1 \leq 0.002:\\
\;\;\;\;\left|\sin th \cdot \frac{ky}{\sin kx}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001

    1. Initial program 83.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\sin th \cdot \sin th}} \]
      3. pow220.8%

        \[\leadsto \sqrt{\color{blue}{{\sin th}^{2}}} \]
    7. Applied egg-rr20.8%

      \[\leadsto \color{blue}{\sqrt{{\sin th}^{2}}} \]

    if -0.10000000000000001 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2e-190

    1. Initial program 99.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e-190 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2e-3

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sin ky \cdot \color{blue}{\frac{1}{\frac{\sin kx}{\sin th}}} \]
      2. un-div-inv45.3%

        \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\sin kx}{\sin th}}} \]
    7. Applied egg-rr45.3%

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

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

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

        \[\leadsto \sqrt{\color{blue}{{\left(\frac{\sin ky}{\frac{\sin kx}{\sin th}}\right)}^{2}}} \]
      4. div-inv47.0%

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

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

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

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

        \[\leadsto \color{blue}{\left|\sin ky \cdot \frac{\sin th}{\sin kx}\right|} \]
      3. associate-*r/59.7%

        \[\leadsto \left|\color{blue}{\frac{\sin ky \cdot \sin th}{\sin kx}}\right| \]
      4. associate-*l/59.7%

        \[\leadsto \left|\color{blue}{\frac{\sin ky}{\sin kx} \cdot \sin th}\right| \]
      5. *-commutative59.7%

        \[\leadsto \left|\color{blue}{\sin th \cdot \frac{\sin ky}{\sin kx}}\right| \]
    11. Simplified59.7%

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

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

    if 2e-3 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 52.0% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ \mathbf{if}\;t\_1 \leq -0.1:\\ \;\;\;\;\sqrt{{\sin th}^{2}}\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-190}:\\ \;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\ \mathbf{elif}\;t\_1 \leq 0.002:\\ \;\;\;\;\left|ky \cdot \frac{\sin th}{\sin kx}\right|\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
   (if (<= t_1 -0.1)
     (sqrt (pow (sin th) 2.0))
     (if (<= t_1 2e-190)
       (/ (sin th) (/ (sin kx) ky))
       (if (<= t_1 0.002) (fabs (* ky (/ (sin th) (sin kx)))) (sin th))))))
double code(double kx, double ky, double th) {
	double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
	double tmp;
	if (t_1 <= -0.1) {
		tmp = sqrt(pow(sin(th), 2.0));
	} else if (t_1 <= 2e-190) {
		tmp = sin(th) / (sin(kx) / ky);
	} else if (t_1 <= 0.002) {
		tmp = fabs((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) :: t_1
    real(8) :: tmp
    t_1 = sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))
    if (t_1 <= (-0.1d0)) then
        tmp = sqrt((sin(th) ** 2.0d0))
    else if (t_1 <= 2d-190) then
        tmp = sin(th) / (sin(kx) / ky)
    else if (t_1 <= 0.002d0) then
        tmp = abs((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 t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)));
	double tmp;
	if (t_1 <= -0.1) {
		tmp = Math.sqrt(Math.pow(Math.sin(th), 2.0));
	} else if (t_1 <= 2e-190) {
		tmp = Math.sin(th) / (Math.sin(kx) / ky);
	} else if (t_1 <= 0.002) {
		tmp = Math.abs((ky * (Math.sin(th) / Math.sin(kx))));
	} else {
		tmp = Math.sin(th);
	}
	return tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))
	tmp = 0
	if t_1 <= -0.1:
		tmp = math.sqrt(math.pow(math.sin(th), 2.0))
	elif t_1 <= 2e-190:
		tmp = math.sin(th) / (math.sin(kx) / ky)
	elif t_1 <= 0.002:
		tmp = math.fabs((ky * (math.sin(th) / math.sin(kx))))
	else:
		tmp = math.sin(th)
	return tmp
function code(kx, ky, th)
	t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))
	tmp = 0.0
	if (t_1 <= -0.1)
		tmp = sqrt((sin(th) ^ 2.0));
	elseif (t_1 <= 2e-190)
		tmp = Float64(sin(th) / Float64(sin(kx) / ky));
	elseif (t_1 <= 0.002)
		tmp = abs(Float64(ky * Float64(sin(th) / sin(kx))));
	else
		tmp = sin(th);
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)));
	tmp = 0.0;
	if (t_1 <= -0.1)
		tmp = sqrt((sin(th) ^ 2.0));
	elseif (t_1 <= 2e-190)
		tmp = sin(th) / (sin(kx) / ky);
	elseif (t_1 <= 0.002)
		tmp = abs((ky * (sin(th) / sin(kx))));
	else
		tmp = sin(th);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, -0.1], N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 2e-190], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.002], N[Abs[N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_1 \leq -0.1:\\
\;\;\;\;\sqrt{{\sin th}^{2}}\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-190}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\

\mathbf{elif}\;t\_1 \leq 0.002:\\
\;\;\;\;\left|ky \cdot \frac{\sin th}{\sin kx}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001

    1. Initial program 83.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\sin th \cdot \sin th}} \]
      3. pow220.8%

        \[\leadsto \sqrt{\color{blue}{{\sin th}^{2}}} \]
    7. Applied egg-rr20.8%

      \[\leadsto \color{blue}{\sqrt{{\sin th}^{2}}} \]

    if -0.10000000000000001 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2e-190

    1. Initial program 99.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e-190 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2e-3

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{{\left(\frac{\sin th}{\frac{\sin kx}{ky}}\right)}^{2}}} \]
      4. div-inv46.9%

        \[\leadsto \sqrt{{\color{blue}{\left(\sin th \cdot \frac{1}{\frac{\sin kx}{ky}}\right)}}^{2}} \]
      5. clear-num46.9%

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

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

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

        \[\leadsto \color{blue}{\left|\sin th \cdot \frac{ky}{\sin kx}\right|} \]
      3. associate-*r/59.6%

        \[\leadsto \left|\color{blue}{\frac{\sin th \cdot ky}{\sin kx}}\right| \]
      4. associate-*l/59.8%

        \[\leadsto \left|\color{blue}{\frac{\sin th}{\sin kx} \cdot ky}\right| \]
      5. *-commutative59.8%

        \[\leadsto \left|\color{blue}{ky \cdot \frac{\sin th}{\sin kx}}\right| \]
    11. Simplified59.8%

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

    if 2e-3 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 64.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ \mathbf{if}\;t\_1 \leq -0.05:\\ \;\;\;\;\sqrt{{\sin th}^{2}}\\ \mathbf{elif}\;t\_1 \leq 0.002:\\ \;\;\;\;\frac{\sin th}{\frac{\left|\sin kx\right|}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
   (if (<= t_1 -0.05)
     (sqrt (pow (sin th) 2.0))
     (if (<= t_1 0.002) (/ (sin th) (/ (fabs (sin kx)) ky)) (sin th)))))
double code(double kx, double ky, double th) {
	double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
	double tmp;
	if (t_1 <= -0.05) {
		tmp = sqrt(pow(sin(th), 2.0));
	} else if (t_1 <= 0.002) {
		tmp = sin(th) / (fabs(sin(kx)) / ky);
	} else {
		tmp = sin(th);
	}
	return tmp;
}
real(8) function code(kx, ky, th)
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    real(8) :: t_1
    real(8) :: tmp
    t_1 = sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))
    if (t_1 <= (-0.05d0)) then
        tmp = sqrt((sin(th) ** 2.0d0))
    else if (t_1 <= 0.002d0) then
        tmp = sin(th) / (abs(sin(kx)) / ky)
    else
        tmp = sin(th)
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)));
	double tmp;
	if (t_1 <= -0.05) {
		tmp = Math.sqrt(Math.pow(Math.sin(th), 2.0));
	} else if (t_1 <= 0.002) {
		tmp = Math.sin(th) / (Math.abs(Math.sin(kx)) / ky);
	} else {
		tmp = Math.sin(th);
	}
	return tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))
	tmp = 0
	if t_1 <= -0.05:
		tmp = math.sqrt(math.pow(math.sin(th), 2.0))
	elif t_1 <= 0.002:
		tmp = math.sin(th) / (math.fabs(math.sin(kx)) / ky)
	else:
		tmp = math.sin(th)
	return tmp
function code(kx, ky, th)
	t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))
	tmp = 0.0
	if (t_1 <= -0.05)
		tmp = sqrt((sin(th) ^ 2.0));
	elseif (t_1 <= 0.002)
		tmp = Float64(sin(th) / Float64(abs(sin(kx)) / ky));
	else
		tmp = sin(th);
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)));
	tmp = 0.0;
	if (t_1 <= -0.05)
		tmp = sqrt((sin(th) ^ 2.0));
	elseif (t_1 <= 0.002)
		tmp = sin(th) / (abs(sin(kx)) / ky);
	else
		tmp = sin(th);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, -0.05], N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 0.002], N[(N[Sin[th], $MachinePrecision] / N[(N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_1 \leq -0.05:\\
\;\;\;\;\sqrt{{\sin th}^{2}}\\

\mathbf{elif}\;t\_1 \leq 0.002:\\
\;\;\;\;\frac{\sin th}{\frac{\left|\sin kx\right|}{ky}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.050000000000000003

    1. Initial program 83.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\sin th \cdot \sin th}} \]
      3. pow220.8%

        \[\leadsto \sqrt{\color{blue}{{\sin th}^{2}}} \]
    7. Applied egg-rr20.8%

      \[\leadsto \color{blue}{\sqrt{{\sin th}^{2}}} \]

    if -0.050000000000000003 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2e-3

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sin th}{\frac{\sqrt{\color{blue}{{\sin kx}^{2}}}}{ky}} \]
    9. Applied egg-rr97.7%

      \[\leadsto \frac{\sin th}{\frac{\color{blue}{\sqrt{{\sin kx}^{2}}}}{ky}} \]
    10. Step-by-step derivation
      1. unpow297.7%

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

        \[\leadsto \frac{\sin th}{\frac{\color{blue}{\left|\sin kx\right|}}{ky}} \]
    11. Simplified98.0%

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

    if 2e-3 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 46.1% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-190}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\

\mathbf{elif}\;t\_1 \leq 0.002:\\
\;\;\;\;\left|\sin th \cdot \frac{ky}{\sin kx}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2e-190

    1. Initial program 91.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e-190 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2e-3

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sin ky \cdot \color{blue}{\frac{1}{\frac{\sin kx}{\sin th}}} \]
      2. un-div-inv45.3%

        \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\sin kx}{\sin th}}} \]
    7. Applied egg-rr45.3%

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

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

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

        \[\leadsto \sqrt{\color{blue}{{\left(\frac{\sin ky}{\frac{\sin kx}{\sin th}}\right)}^{2}}} \]
      4. div-inv47.0%

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

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

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

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

        \[\leadsto \color{blue}{\left|\sin ky \cdot \frac{\sin th}{\sin kx}\right|} \]
      3. associate-*r/59.7%

        \[\leadsto \left|\color{blue}{\frac{\sin ky \cdot \sin th}{\sin kx}}\right| \]
      4. associate-*l/59.7%

        \[\leadsto \left|\color{blue}{\frac{\sin ky}{\sin kx} \cdot \sin th}\right| \]
      5. *-commutative59.7%

        \[\leadsto \left|\color{blue}{\sin th \cdot \frac{\sin ky}{\sin kx}}\right| \]
    11. Simplified59.7%

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

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

    if 2e-3 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 51.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ \mathbf{if}\;t\_1 \leq -0.1:\\ \;\;\;\;\sqrt{{\sin th}^{2}}\\ \mathbf{elif}\;t\_1 \leq 0.002:\\ \;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
   (if (<= t_1 -0.1)
     (sqrt (pow (sin th) 2.0))
     (if (<= t_1 0.002) (/ (sin th) (/ (sin kx) ky)) (sin th)))))
double code(double kx, double ky, double th) {
	double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
	double tmp;
	if (t_1 <= -0.1) {
		tmp = sqrt(pow(sin(th), 2.0));
	} else if (t_1 <= 0.002) {
		tmp = sin(th) / (sin(kx) / ky);
	} else {
		tmp = sin(th);
	}
	return tmp;
}
real(8) function code(kx, ky, th)
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    real(8) :: t_1
    real(8) :: tmp
    t_1 = sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))
    if (t_1 <= (-0.1d0)) then
        tmp = sqrt((sin(th) ** 2.0d0))
    else if (t_1 <= 0.002d0) then
        tmp = sin(th) / (sin(kx) / ky)
    else
        tmp = sin(th)
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)));
	double tmp;
	if (t_1 <= -0.1) {
		tmp = Math.sqrt(Math.pow(Math.sin(th), 2.0));
	} else if (t_1 <= 0.002) {
		tmp = Math.sin(th) / (Math.sin(kx) / ky);
	} else {
		tmp = Math.sin(th);
	}
	return tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))
	tmp = 0
	if t_1 <= -0.1:
		tmp = math.sqrt(math.pow(math.sin(th), 2.0))
	elif t_1 <= 0.002:
		tmp = math.sin(th) / (math.sin(kx) / ky)
	else:
		tmp = math.sin(th)
	return tmp
function code(kx, ky, th)
	t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))
	tmp = 0.0
	if (t_1 <= -0.1)
		tmp = sqrt((sin(th) ^ 2.0));
	elseif (t_1 <= 0.002)
		tmp = Float64(sin(th) / Float64(sin(kx) / ky));
	else
		tmp = sin(th);
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)));
	tmp = 0.0;
	if (t_1 <= -0.1)
		tmp = sqrt((sin(th) ^ 2.0));
	elseif (t_1 <= 0.002)
		tmp = sin(th) / (sin(kx) / ky);
	else
		tmp = sin(th);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, -0.1], N[Sqrt[N[Power[N[Sin[th], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 0.002], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_1 \leq -0.1:\\
\;\;\;\;\sqrt{{\sin th}^{2}}\\

\mathbf{elif}\;t\_1 \leq 0.002:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001

    1. Initial program 83.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\sin th \cdot \sin th}} \]
      3. pow220.8%

        \[\leadsto \sqrt{\color{blue}{{\sin th}^{2}}} \]
    7. Applied egg-rr20.8%

      \[\leadsto \color{blue}{\sqrt{{\sin th}^{2}}} \]

    if -0.10000000000000001 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2e-3

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e-3 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 45.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ \mathbf{if}\;t\_1 \leq -0.05:\\ \;\;\;\;\left|\sin th\right|\\ \mathbf{elif}\;t\_1 \leq 0.002:\\ \;\;\;\;\left|th \cdot \frac{ky}{\sin kx}\right|\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))))
   (if (<= t_1 -0.05)
     (fabs (sin th))
     (if (<= t_1 0.002) (fabs (* th (/ ky (sin kx)))) (sin th)))))
double code(double kx, double ky, double th) {
	double t_1 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
	double tmp;
	if (t_1 <= -0.05) {
		tmp = fabs(sin(th));
	} else if (t_1 <= 0.002) {
		tmp = fabs((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) :: t_1
    real(8) :: tmp
    t_1 = sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))
    if (t_1 <= (-0.05d0)) then
        tmp = abs(sin(th))
    else if (t_1 <= 0.002d0) then
        tmp = abs((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 t_1 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)));
	double tmp;
	if (t_1 <= -0.05) {
		tmp = Math.abs(Math.sin(th));
	} else if (t_1 <= 0.002) {
		tmp = Math.abs((th * (ky / Math.sin(kx))));
	} else {
		tmp = Math.sin(th);
	}
	return tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))
	tmp = 0
	if t_1 <= -0.05:
		tmp = math.fabs(math.sin(th))
	elif t_1 <= 0.002:
		tmp = math.fabs((th * (ky / math.sin(kx))))
	else:
		tmp = math.sin(th)
	return tmp
function code(kx, ky, th)
	t_1 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))
	tmp = 0.0
	if (t_1 <= -0.05)
		tmp = abs(sin(th));
	elseif (t_1 <= 0.002)
		tmp = abs(Float64(th * Float64(ky / sin(kx))));
	else
		tmp = sin(th);
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)));
	tmp = 0.0;
	if (t_1 <= -0.05)
		tmp = abs(sin(th));
	elseif (t_1 <= 0.002)
		tmp = abs((th * (ky / sin(kx))));
	else
		tmp = sin(th);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, -0.05], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 0.002], N[Abs[N[(th * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_1 \leq -0.05:\\
\;\;\;\;\left|\sin th\right|\\

\mathbf{elif}\;t\_1 \leq 0.002:\\
\;\;\;\;\left|th \cdot \frac{ky}{\sin kx}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.050000000000000003

    1. Initial program 83.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\sin th} \cdot \sqrt{\sin th}} \]
      2. pow21.7%

        \[\leadsto \color{blue}{{\left(\sqrt{\sin th}\right)}^{2}} \]
    7. Applied egg-rr1.7%

      \[\leadsto \color{blue}{{\left(\sqrt{\sin th}\right)}^{2}} \]
    8. Step-by-step derivation
      1. unpow21.7%

        \[\leadsto \color{blue}{\sqrt{\sin th} \cdot \sqrt{\sin th}} \]
      2. fabs-sqr1.7%

        \[\leadsto \color{blue}{\left|\sqrt{\sin th} \cdot \sqrt{\sin th}\right|} \]
      3. add-sqr-sqrt29.8%

        \[\leadsto \left|\color{blue}{\sin th}\right| \]
    9. Applied egg-rr29.8%

      \[\leadsto \color{blue}{\left|\sin th\right|} \]

    if -0.050000000000000003 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2e-3

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{ky}{\frac{\sin kx}{th}}\right|} \]
      3. associate-/r/32.7%

        \[\leadsto \left|\color{blue}{\frac{ky}{\sin kx} \cdot th}\right| \]
      4. rem-square-sqrt16.9%

        \[\leadsto \left|\frac{ky}{\sin kx} \cdot \color{blue}{\left(\sqrt{th} \cdot \sqrt{th}\right)}\right| \]
      5. /-rgt-identity16.9%

        \[\leadsto \left|\frac{ky}{\sin kx} \cdot \left(\sqrt{th} \cdot \color{blue}{\frac{\sqrt{th}}{1}}\right)\right| \]
      6. associate-*r/16.9%

        \[\leadsto \left|\frac{ky}{\sin kx} \cdot \color{blue}{\frac{\sqrt{th} \cdot \sqrt{th}}{1}}\right| \]
      7. rem-square-sqrt32.7%

        \[\leadsto \left|\frac{ky}{\sin kx} \cdot \frac{\color{blue}{th}}{1}\right| \]
      8. times-frac31.1%

        \[\leadsto \left|\color{blue}{\frac{ky \cdot th}{\sin kx \cdot 1}}\right| \]
      9. *-commutative31.1%

        \[\leadsto \left|\frac{\color{blue}{th \cdot ky}}{\sin kx \cdot 1}\right| \]
      10. *-rgt-identity31.1%

        \[\leadsto \left|\frac{th \cdot ky}{\color{blue}{\sin kx}}\right| \]
      11. associate-/l*32.7%

        \[\leadsto \left|\color{blue}{th \cdot \frac{ky}{\sin kx}}\right| \]
    14. Simplified32.7%

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

    if 2e-3 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 44.5% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.002:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2e-3

    1. Initial program 92.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e-3 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 36.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.002:\\ \;\;\;\;ky \cdot \frac{\sin th}{kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 0.002)
   (* ky (/ (sin th) kx))
   (sin th)))
double code(double kx, double ky, double th) {
	double tmp;
	if ((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) <= 0.002) {
		tmp = ky * (sin(th) / kx);
	} else {
		tmp = sin(th);
	}
	return tmp;
}
real(8) function code(kx, ky, th)
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    real(8) :: tmp
    if ((sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) <= 0.002d0) then
        tmp = ky * (sin(th) / kx)
    else
        tmp = sin(th)
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double tmp;
	if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) <= 0.002) {
		tmp = ky * (Math.sin(th) / kx);
	} else {
		tmp = Math.sin(th);
	}
	return tmp;
}
def code(kx, ky, th):
	tmp = 0
	if (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) <= 0.002:
		tmp = ky * (math.sin(th) / kx)
	else:
		tmp = math.sin(th)
	return tmp
function code(kx, ky, th)
	tmp = 0.0
	if (Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 0.002)
		tmp = Float64(ky * Float64(sin(th) / kx));
	else
		tmp = sin(th);
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	tmp = 0.0;
	if ((sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 0.002)
		tmp = ky * (sin(th) / kx);
	else
		tmp = sin(th);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := If[LessEqual[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], 0.002], N[(ky * N[(N[Sin[th], $MachinePrecision] / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.002:\\
\;\;\;\;ky \cdot \frac{\sin th}{kx}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2e-3

    1. Initial program 92.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{ky \cdot \frac{\sin th}{kx}} \]
    10. Simplified22.2%

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

    if 2e-3 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 36.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.002:\\
\;\;\;\;ky \cdot \frac{th}{\sin kx}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2e-3

    1. Initial program 92.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{ky \cdot \frac{th}{\sin kx}} \]
    10. Simplified21.2%

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

    if 2e-3 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 33.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.002:\\ \;\;\;\;ky \cdot \frac{th}{kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 0.002)
   (* ky (/ th kx))
   (sin th)))
double code(double kx, double ky, double th) {
	double tmp;
	if ((sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) <= 0.002) {
		tmp = ky * (th / kx);
	} else {
		tmp = sin(th);
	}
	return tmp;
}
real(8) function code(kx, ky, th)
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    real(8) :: tmp
    if ((sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) <= 0.002d0) then
        tmp = ky * (th / kx)
    else
        tmp = sin(th)
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double tmp;
	if ((Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) <= 0.002) {
		tmp = ky * (th / kx);
	} else {
		tmp = Math.sin(th);
	}
	return tmp;
}
def code(kx, ky, th):
	tmp = 0
	if (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) <= 0.002:
		tmp = ky * (th / kx)
	else:
		tmp = math.sin(th)
	return tmp
function code(kx, ky, th)
	tmp = 0.0
	if (Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 0.002)
		tmp = Float64(ky * Float64(th / kx));
	else
		tmp = sin(th);
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	tmp = 0.0;
	if ((sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) <= 0.002)
		tmp = ky * (th / kx);
	else
		tmp = sin(th);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := If[LessEqual[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], 0.002], N[(ky * N[(th / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.002:\\
\;\;\;\;ky \cdot \frac{th}{kx}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2e-3

    1. Initial program 92.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{ky \cdot \frac{th}{\sin kx}} \]
    10. Simplified21.2%

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

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

    if 2e-3 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 23.7% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.002:\\
\;\;\;\;ky \cdot \frac{th}{kx}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 2e-3

    1. Initial program 92.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{ky \cdot \frac{th}{\sin kx}} \]
    10. Simplified21.2%

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

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

    if 2e-3 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64)))))

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 70.9% accurate, 1.4× speedup?

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

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

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

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.0100000000000000002 < (sin.f64 ky) < 0.20000000000000001

    1. Initial program 84.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.20000000000000001 < (sin.f64 ky)

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 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 90.8%

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

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

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

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

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

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

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

Alternative 15: 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 90.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 66.4% accurate, 1.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if th < 8.00000000000000065e-5

    1. Initial program 92.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.00000000000000065e-5 < th

    1. Initial program 85.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 17: 66.4% accurate, 1.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if th < 3.8000000000000002e-5

    1. Initial program 92.4%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin \left(-kx\right)}^{2} + {\sin ky}^{2}}}} \]
      7. associate-/l*92.4%

        \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\sqrt{{\sin \left(-kx\right)}^{2} + {\sin ky}^{2}}}} \]
      8. +-commutative92.4%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin \left(-kx\right)}^{2}}}} \]
      9. unpow292.4%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{{\sin ky}^{2} + \color{blue}{\sin \left(-kx\right) \cdot \sin \left(-kx\right)}}} \]
      10. sin-neg92.4%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{{\sin ky}^{2} + \color{blue}{\left(-\sin kx\right)} \cdot \sin \left(-kx\right)}} \]
      11. sin-neg92.4%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{{\sin ky}^{2} + \left(-\sin kx\right) \cdot \color{blue}{\left(-\sin kx\right)}}} \]
    3. Simplified99.6%

      \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in th around 0 68.7%

      \[\leadsto \sin ky \cdot \frac{\color{blue}{th}}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \]

    if 3.8000000000000002e-5 < th

    1. Initial program 85.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. unpow285.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      2. sqr-neg85.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(-\sin kx\right) \cdot \left(-\sin kx\right)} + {\sin ky}^{2}}} \cdot \sin th \]
      3. sin-neg85.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin \left(-kx\right)} \cdot \left(-\sin kx\right) + {\sin ky}^{2}}} \cdot \sin th \]
      4. sin-neg85.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin \left(-kx\right) \cdot \color{blue}{\sin \left(-kx\right)} + {\sin ky}^{2}}} \cdot \sin th \]
      5. unpow285.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin \left(-kx\right)}^{2}} + {\sin ky}^{2}}} \cdot \sin th \]
      6. associate-*l/85.7%

        \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin \left(-kx\right)}^{2} + {\sin ky}^{2}}}} \]
      7. associate-/l*85.8%

        \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\sqrt{{\sin \left(-kx\right)}^{2} + {\sin ky}^{2}}}} \]
      8. +-commutative85.8%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin \left(-kx\right)}^{2}}}} \]
      9. unpow285.8%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{{\sin ky}^{2} + \color{blue}{\sin \left(-kx\right) \cdot \sin \left(-kx\right)}}} \]
      10. sin-neg85.8%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{{\sin ky}^{2} + \color{blue}{\left(-\sin kx\right)} \cdot \sin \left(-kx\right)}} \]
      11. sin-neg85.8%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{{\sin ky}^{2} + \left(-\sin kx\right) \cdot \color{blue}{\left(-\sin kx\right)}}} \]
    3. Simplified99.6%

      \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in ky around 0 53.9%

      \[\leadsto \sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\color{blue}{ky}, \sin kx\right)} \]
    6. Taylor expanded in ky around 0 69.3%

      \[\leadsto \color{blue}{ky} \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 18: 70.0% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin ky \leq 0.2:\\ \;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= (sin ky) 0.2) (* ky (/ (sin th) (hypot ky (sin kx)))) (sin th)))
double code(double kx, double ky, double th) {
	double tmp;
	if (sin(ky) <= 0.2) {
		tmp = ky * (sin(th) / hypot(ky, sin(kx)));
	} else {
		tmp = sin(th);
	}
	return tmp;
}
public static double code(double kx, double ky, double th) {
	double tmp;
	if (Math.sin(ky) <= 0.2) {
		tmp = ky * (Math.sin(th) / Math.hypot(ky, Math.sin(kx)));
	} else {
		tmp = Math.sin(th);
	}
	return tmp;
}
def code(kx, ky, th):
	tmp = 0
	if math.sin(ky) <= 0.2:
		tmp = ky * (math.sin(th) / math.hypot(ky, math.sin(kx)))
	else:
		tmp = math.sin(th)
	return tmp
function code(kx, ky, th)
	tmp = 0.0
	if (sin(ky) <= 0.2)
		tmp = Float64(ky * Float64(sin(th) / hypot(ky, sin(kx))));
	else
		tmp = sin(th);
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	tmp = 0.0;
	if (sin(ky) <= 0.2)
		tmp = ky * (sin(th) / hypot(ky, sin(kx)));
	else
		tmp = sin(th);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 0.2], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 0.2:\\
\;\;\;\;ky \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)}\\

\mathbf{else}:\\
\;\;\;\;\sin th\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sin.f64 ky) < 0.20000000000000001

    1. Initial program 88.3%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. unpow288.3%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      2. sqr-neg88.3%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(-\sin kx\right) \cdot \left(-\sin kx\right)} + {\sin ky}^{2}}} \cdot \sin th \]
      3. sin-neg88.3%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin \left(-kx\right)} \cdot \left(-\sin kx\right) + {\sin ky}^{2}}} \cdot \sin th \]
      4. sin-neg88.3%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin \left(-kx\right) \cdot \color{blue}{\sin \left(-kx\right)} + {\sin ky}^{2}}} \cdot \sin th \]
      5. unpow288.3%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin \left(-kx\right)}^{2}} + {\sin ky}^{2}}} \cdot \sin th \]
      6. associate-*l/85.4%

        \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin \left(-kx\right)}^{2} + {\sin ky}^{2}}}} \]
      7. associate-/l*88.3%

        \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\sqrt{{\sin \left(-kx\right)}^{2} + {\sin ky}^{2}}}} \]
      8. +-commutative88.3%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin \left(-kx\right)}^{2}}}} \]
      9. unpow288.3%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{{\sin ky}^{2} + \color{blue}{\sin \left(-kx\right) \cdot \sin \left(-kx\right)}}} \]
      10. sin-neg88.3%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{{\sin ky}^{2} + \color{blue}{\left(-\sin kx\right)} \cdot \sin \left(-kx\right)}} \]
      11. sin-neg88.3%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{{\sin ky}^{2} + \left(-\sin kx\right) \cdot \color{blue}{\left(-\sin kx\right)}}} \]
    3. Simplified99.6%

      \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in ky around 0 71.2%

      \[\leadsto \sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\color{blue}{ky}, \sin kx\right)} \]
    6. Taylor expanded in ky around 0 77.7%

      \[\leadsto \color{blue}{ky} \cdot \frac{\sin th}{\mathsf{hypot}\left(ky, \sin kx\right)} \]

    if 0.20000000000000001 < (sin.f64 ky)

    1. Initial program 99.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. unpow299.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      2. sqr-neg99.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(-\sin kx\right) \cdot \left(-\sin kx\right)} + {\sin ky}^{2}}} \cdot \sin th \]
      3. sin-neg99.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin \left(-kx\right)} \cdot \left(-\sin kx\right) + {\sin ky}^{2}}} \cdot \sin th \]
      4. sin-neg99.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\sin \left(-kx\right) \cdot \color{blue}{\sin \left(-kx\right)} + {\sin ky}^{2}}} \cdot \sin th \]
      5. unpow299.7%

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin \left(-kx\right)}^{2}} + {\sin ky}^{2}}} \cdot \sin th \]
      6. associate-*l/99.5%

        \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin \left(-kx\right)}^{2} + {\sin ky}^{2}}}} \]
      7. associate-/l*99.6%

        \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\sqrt{{\sin \left(-kx\right)}^{2} + {\sin ky}^{2}}}} \]
      8. +-commutative99.6%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin \left(-kx\right)}^{2}}}} \]
      9. unpow299.6%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{{\sin ky}^{2} + \color{blue}{\sin \left(-kx\right) \cdot \sin \left(-kx\right)}}} \]
      10. sin-neg99.6%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{{\sin ky}^{2} + \color{blue}{\left(-\sin kx\right)} \cdot \sin \left(-kx\right)}} \]
      11. sin-neg99.6%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{{\sin ky}^{2} + \left(-\sin kx\right) \cdot \color{blue}{\left(-\sin kx\right)}}} \]
    3. Simplified99.6%

      \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in kx around 0 51.3%

      \[\leadsto \color{blue}{\sin th} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 19: 13.7% 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 90.8%

    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
  2. Step-by-step derivation
    1. unpow290.8%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
    2. sqr-neg90.8%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(-\sin kx\right) \cdot \left(-\sin kx\right)} + {\sin ky}^{2}}} \cdot \sin th \]
    3. sin-neg90.8%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin \left(-kx\right)} \cdot \left(-\sin kx\right) + {\sin ky}^{2}}} \cdot \sin th \]
    4. sin-neg90.8%

      \[\leadsto \frac{\sin ky}{\sqrt{\sin \left(-kx\right) \cdot \color{blue}{\sin \left(-kx\right)} + {\sin ky}^{2}}} \cdot \sin th \]
    5. unpow290.8%

      \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin \left(-kx\right)}^{2}} + {\sin ky}^{2}}} \cdot \sin th \]
    6. associate-*l/88.5%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin \left(-kx\right)}^{2} + {\sin ky}^{2}}}} \]
    7. associate-/l*90.8%

      \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\sqrt{{\sin \left(-kx\right)}^{2} + {\sin ky}^{2}}}} \]
    8. +-commutative90.8%

      \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin \left(-kx\right)}^{2}}}} \]
    9. unpow290.8%

      \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{{\sin ky}^{2} + \color{blue}{\sin \left(-kx\right) \cdot \sin \left(-kx\right)}}} \]
    10. sin-neg90.8%

      \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{{\sin ky}^{2} + \color{blue}{\left(-\sin kx\right)} \cdot \sin \left(-kx\right)}} \]
    11. sin-neg90.8%

      \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{{\sin ky}^{2} + \left(-\sin kx\right) \cdot \color{blue}{\left(-\sin kx\right)}}} \]
  3. Simplified99.6%

    \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in kx around 0 18.4%

    \[\leadsto \color{blue}{\sin th} \]
  6. Taylor expanded in th around 0 10.6%

    \[\leadsto \color{blue}{th} \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2024191 
(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)))