Toniolo and Linder, Equation (3b), real

Percentage Accurate: 60.9% → 75.8%
Time: 33.2s
Alternatives: 20
Speedup: 1.2×

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 20 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: 60.9% 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: 75.8% accurate, 1.2× speedup?

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

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

\mathbf{elif}\;ky \leq 75000000:\\
\;\;\;\;\frac{\sin ky \cdot \left|\sin th\right|}{t_1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if ky < -2.60000000000000009

    1. Initial program 50.2%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt42.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.60000000000000009 < ky < 7.5e7

    1. Initial program 71.3%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt50.9%

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

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

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

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

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

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

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

    if 7.5e7 < ky

    1. Initial program 44.1%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 67.9% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;\sin th \leq -0.02:\\
\;\;\;\;\left|\sin th\right|\\

\mathbf{elif}\;\sin th \leq 3.2 \cdot 10^{-139}:\\
\;\;\;\;th \cdot \frac{t_2}{t_1}\\

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


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

    1. Initial program 26.7%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt0.5%

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

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

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

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

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

    if -0.859999999999999987 < (sin.f64 th) < -0.0200000000000000004

    1. Initial program 39.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

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

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

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

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

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

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

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

    if -0.0200000000000000004 < (sin.f64 th) < 3.1999999999999999e-139

    1. Initial program 62.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt43.7%

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

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

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

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

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

    if 3.1999999999999999e-139 < (sin.f64 th)

    1. Initial program 69.4%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 75.8% accurate, 1.2× speedup?

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

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

\mathbf{elif}\;th \leq 3.2 \cdot 10^{-139}:\\
\;\;\;\;th \cdot \frac{\left|\sin ky\right|}{t_1}\\

\mathbf{elif}\;th \leq 1.32 \cdot 10^{+66}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{t_1}\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if th < -1.02e8 or 1.32000000000000009e66 < th

    1. Initial program 47.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt33.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.02e8 < th < 3.1999999999999999e-139

    1. Initial program 62.2%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt43.8%

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

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

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

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

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

    if 3.1999999999999999e-139 < th < 1.32000000000000009e66

    1. Initial program 77.8%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;th \leq -102000000:\\ \;\;\;\;\left|\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}}\right|\\ \mathbf{elif}\;th \leq 3.2 \cdot 10^{-139}:\\ \;\;\;\;th \cdot \frac{\left|\sin ky\right|}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{elif}\;th \leq 1.32 \cdot 10^{+66}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}}\right|\\ \end{array} \]

Alternative 4: 73.7% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
t_2 := \frac{\sin th}{t_1}\\
\mathbf{if}\;ky \leq -3.2 \cdot 10^{+15}:\\
\;\;\;\;\left|\frac{\sin th}{\frac{t_1}{\sin ky}}\right|\\

\mathbf{elif}\;ky \leq -1.6 \cdot 10^{-233}:\\
\;\;\;\;\sin ky \cdot t_2\\

\mathbf{else}:\\
\;\;\;\;\left|\sin ky\right| \cdot t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if ky < -3.2e15

    1. Initial program 47.7%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt40.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.2e15 < ky < -1.5999999999999999e-233

    1. Initial program 72.9%

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

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

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

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

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

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

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

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

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

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

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

    if -1.5999999999999999e-233 < ky

    1. Initial program 55.5%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt41.9%

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

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

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

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

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

Alternative 5: 73.8% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
\mathbf{if}\;ky \leq -3.2 \cdot 10^{+15}:\\
\;\;\;\;\left|\frac{\sin th}{\frac{t_1}{\sin ky}}\right|\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if ky < -3.2e15

    1. Initial program 47.7%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt40.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.2e15 < ky < -1.5999999999999999e-233

    1. Initial program 72.9%

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

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

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

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

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

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

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

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

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

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

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

    if -1.5999999999999999e-233 < ky

    1. Initial program 55.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt41.9%

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

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

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

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

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

Alternative 6: 77.5% accurate, 1.2× speedup?

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

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

\mathbf{elif}\;ky \leq 170000000:\\
\;\;\;\;\left|\sin th\right| \cdot \frac{\sin ky}{t_1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if ky < -2.60000000000000009

    1. Initial program 50.2%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt42.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.60000000000000009 < ky < 1.7e8

    1. Initial program 71.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt50.9%

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

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

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

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

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

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

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

    if 1.7e8 < ky

    1. Initial program 44.1%

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 48.7% accurate, 1.4× speedup?

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

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

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


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

    1. Initial program 56.0%

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

      \[\leadsto \frac{\sin ky}{\color{blue}{\sin ky + 0.5 \cdot \frac{{kx}^{2}}{\sin ky}}} \cdot \sin th \]
    3. Step-by-step derivation
      1. unpow245.4%

        \[\leadsto \frac{\sin ky}{\sin ky + 0.5 \cdot \frac{\color{blue}{kx \cdot kx}}{\sin ky}} \cdot \sin th \]
    4. Simplified45.4%

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

    if 1.05000000000000001e-80 < kx

    1. Initial program 61.5%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 49.6% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_1 := \sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\
\mathbf{if}\;ky \leq -0.029:\\
\;\;\;\;\left|\sin th\right|\\

\mathbf{elif}\;ky \leq -1.85 \cdot 10^{-79}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;ky \leq 3.8 \cdot 10^{-162}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;ky \leq 1.76 \cdot 10^{-16}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if ky < -0.0290000000000000015

    1. Initial program 50.2%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt25.9%

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

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

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

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

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

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

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

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

    if -0.0290000000000000015 < ky < -1.85000000000000009e-79 or -2.99999999999999977e-274 < ky < 3.80000000000000005e-162 or 1.79999999999999996e-87 < ky < 1.76e-16

    1. Initial program 78.3%

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

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

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

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

        \[\leadsto \frac{\sin ky}{\color{blue}{\left|\sin kx\right|}} \cdot \sin th \]
    4. Applied egg-rr69.2%

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

    if -1.85000000000000009e-79 < ky < -2.99999999999999977e-274

    1. Initial program 58.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.80000000000000005e-162 < ky < 1.79999999999999996e-87

    1. Initial program 80.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.76e-16 < ky

    1. Initial program 46.1%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq -0.029:\\ \;\;\;\;\left|\sin th\right|\\ \mathbf{elif}\;ky \leq -1.85 \cdot 10^{-79}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\ \mathbf{elif}\;ky \leq -3 \cdot 10^{-274}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\ \mathbf{elif}\;ky \leq 3.8 \cdot 10^{-162}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\ \mathbf{elif}\;ky \leq 1.8 \cdot 10^{-87}:\\ \;\;\;\;\frac{ky}{\frac{\mathsf{hypot}\left(\sin ky, kx\right)}{\sin th}}\\ \mathbf{elif}\;ky \leq 1.76 \cdot 10^{-16}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]

Alternative 9: 60.5% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ky \leq -2.1:\\ \;\;\;\;\left|\sin th\right|\\ \mathbf{elif}\;ky \leq 21000000:\\ \;\;\;\;\sin 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 (<= ky -2.1)
   (fabs (sin th))
   (if (<= ky 21000000.0)
     (* (sin ky) (/ (sin th) (hypot ky (sin kx))))
     (sin th))))
double code(double kx, double ky, double th) {
	double tmp;
	if (ky <= -2.1) {
		tmp = fabs(sin(th));
	} else if (ky <= 21000000.0) {
		tmp = sin(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 (ky <= -2.1) {
		tmp = Math.abs(Math.sin(th));
	} else if (ky <= 21000000.0) {
		tmp = Math.sin(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 ky <= -2.1:
		tmp = math.fabs(math.sin(th))
	elif ky <= 21000000.0:
		tmp = math.sin(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 (ky <= -2.1)
		tmp = abs(sin(th));
	elseif (ky <= 21000000.0)
		tmp = Float64(sin(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 (ky <= -2.1)
		tmp = abs(sin(th));
	elseif (ky <= 21000000.0)
		tmp = sin(ky) * (sin(th) / hypot(ky, sin(kx)));
	else
		tmp = sin(th);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := If[LessEqual[ky, -2.1], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[ky, 21000000.0], N[(N[Sin[ky], $MachinePrecision] * 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}\;ky \leq -2.1:\\
\;\;\;\;\left|\sin th\right|\\

\mathbf{elif}\;ky \leq 21000000:\\
\;\;\;\;\sin 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 ky < -2.10000000000000009

    1. Initial program 50.2%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt25.9%

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

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

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

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

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

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

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

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

    if -2.10000000000000009 < ky < 2.1e7

    1. Initial program 71.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.1e7 < ky

    1. Initial program 44.1%

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

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

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

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

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

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

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

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

Alternative 10: 44.8% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left|\sin th\right|\\ \mathbf{if}\;ky \leq -0.25:\\ \;\;\;\;t_1\\ \mathbf{elif}\;ky \leq -4 \cdot 10^{-70}:\\ \;\;\;\;\frac{ky}{\frac{\sin kx}{t_1}}\\ \mathbf{elif}\;ky \leq -7 \cdot 10^{-74}:\\ \;\;\;\;\left|th\right|\\ \mathbf{elif}\;ky \leq 6.6 \cdot 10^{-155}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (fabs (sin th))))
   (if (<= ky -0.25)
     t_1
     (if (<= ky -4e-70)
       (/ ky (/ (sin kx) t_1))
       (if (<= ky -7e-74)
         (fabs th)
         (if (<= ky 6.6e-155) (* (sin ky) (/ (sin th) (sin kx))) (sin th)))))))
double code(double kx, double ky, double th) {
	double t_1 = fabs(sin(th));
	double tmp;
	if (ky <= -0.25) {
		tmp = t_1;
	} else if (ky <= -4e-70) {
		tmp = ky / (sin(kx) / t_1);
	} else if (ky <= -7e-74) {
		tmp = fabs(th);
	} else if (ky <= 6.6e-155) {
		tmp = sin(ky) * (sin(th) / sin(kx));
	} else {
		tmp = sin(th);
	}
	return tmp;
}
real(8) function code(kx, ky, th)
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    real(8) :: t_1
    real(8) :: tmp
    t_1 = abs(sin(th))
    if (ky <= (-0.25d0)) then
        tmp = t_1
    else if (ky <= (-4d-70)) then
        tmp = ky / (sin(kx) / t_1)
    else if (ky <= (-7d-74)) then
        tmp = abs(th)
    else if (ky <= 6.6d-155) then
        tmp = sin(ky) * (sin(th) / sin(kx))
    else
        tmp = sin(th)
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double t_1 = Math.abs(Math.sin(th));
	double tmp;
	if (ky <= -0.25) {
		tmp = t_1;
	} else if (ky <= -4e-70) {
		tmp = ky / (Math.sin(kx) / t_1);
	} else if (ky <= -7e-74) {
		tmp = Math.abs(th);
	} else if (ky <= 6.6e-155) {
		tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
	} else {
		tmp = Math.sin(th);
	}
	return tmp;
}
def code(kx, ky, th):
	t_1 = math.fabs(math.sin(th))
	tmp = 0
	if ky <= -0.25:
		tmp = t_1
	elif ky <= -4e-70:
		tmp = ky / (math.sin(kx) / t_1)
	elif ky <= -7e-74:
		tmp = math.fabs(th)
	elif ky <= 6.6e-155:
		tmp = math.sin(ky) * (math.sin(th) / math.sin(kx))
	else:
		tmp = math.sin(th)
	return tmp
function code(kx, ky, th)
	t_1 = abs(sin(th))
	tmp = 0.0
	if (ky <= -0.25)
		tmp = t_1;
	elseif (ky <= -4e-70)
		tmp = Float64(ky / Float64(sin(kx) / t_1));
	elseif (ky <= -7e-74)
		tmp = abs(th);
	elseif (ky <= 6.6e-155)
		tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx)));
	else
		tmp = sin(th);
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	t_1 = abs(sin(th));
	tmp = 0.0;
	if (ky <= -0.25)
		tmp = t_1;
	elseif (ky <= -4e-70)
		tmp = ky / (sin(kx) / t_1);
	elseif (ky <= -7e-74)
		tmp = abs(th);
	elseif (ky <= 6.6e-155)
		tmp = sin(ky) * (sin(th) / sin(kx));
	else
		tmp = sin(th);
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ky, -0.25], t$95$1, If[LessEqual[ky, -4e-70], N[(ky / N[(N[Sin[kx], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, -7e-74], N[Abs[th], $MachinePrecision], If[LessEqual[ky, 6.6e-155], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left|\sin th\right|\\
\mathbf{if}\;ky \leq -0.25:\\
\;\;\;\;t_1\\

\mathbf{elif}\;ky \leq -4 \cdot 10^{-70}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{t_1}}\\

\mathbf{elif}\;ky \leq -7 \cdot 10^{-74}:\\
\;\;\;\;\left|th\right|\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if ky < -0.25

    1. Initial program 50.2%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt25.9%

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

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

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

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

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

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

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

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

    if -0.25 < ky < -3.99999999999999998e-70

    1. Initial program 83.3%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt74.2%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{ky}{\frac{\sin kx}{\left|\sin th\right|}}} \]
    10. Simplified18.9%

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

    if -3.99999999999999998e-70 < ky < -7.00000000000000029e-74

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.00000000000000029e-74 < ky < 6.59999999999999972e-155

    1. Initial program 65.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.59999999999999972e-155 < ky

    1. Initial program 52.2%

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

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

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

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

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

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

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

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

Alternative 11: 44.9% accurate, 2.3× speedup?

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

\\
\begin{array}{l}
t_1 := \left|\sin th\right|\\
\mathbf{if}\;ky \leq -0.03:\\
\;\;\;\;t_1\\

\mathbf{elif}\;ky \leq -3.7 \cdot 10^{-66}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{t_1}}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if ky < -0.029999999999999999

    1. Initial program 50.2%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt25.9%

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

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

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

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

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

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

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

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

    if -0.029999999999999999 < ky < -3.7000000000000002e-66

    1. Initial program 83.3%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt74.2%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{ky}{\frac{\sin kx}{\left|\sin th\right|}}} \]
    10. Simplified18.9%

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

    if -3.7000000000000002e-66 < ky < -6.00000000000000014e-74

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.00000000000000014e-74 < ky < 7.5000000000000006e-155

    1. Initial program 65.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.5000000000000006e-155 < ky

    1. Initial program 52.2%

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

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

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

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

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

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

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

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

Alternative 12: 44.9% accurate, 2.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;ky \leq -5.5 \cdot 10^{-5}:\\
\;\;\;\;\left|\sin th\right|\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if ky < -5.5000000000000002e-5

    1. Initial program 51.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.5000000000000002e-5 < ky < 7.5000000000000006e-155

    1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.5000000000000006e-155 < ky

    1. Initial program 52.2%

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

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

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

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

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

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

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

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

Alternative 13: 44.9% accurate, 3.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;ky \leq -8 \cdot 10^{-5}:\\
\;\;\;\;\left|\sin th\right|\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if ky < -8.00000000000000065e-5

    1. Initial program 51.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.00000000000000065e-5 < ky < 7.5000000000000006e-155

    1. Initial program 68.5%

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

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

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

    if 7.5000000000000006e-155 < ky

    1. Initial program 52.2%

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

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

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

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

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

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

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

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

Alternative 14: 44.9% accurate, 3.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;ky \leq -8 \cdot 10^{-5}:\\
\;\;\;\;\left|\sin th\right|\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if ky < -8.00000000000000065e-5

    1. Initial program 51.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.00000000000000065e-5 < ky < 7.5000000000000006e-155

    1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

    if 7.5000000000000006e-155 < ky

    1. Initial program 52.2%

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

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

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

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

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

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

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

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

Alternative 15: 37.4% accurate, 3.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;ky \leq -5.7 \cdot 10^{-5}:\\
\;\;\;\;\left|\sin th\right|\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if ky < -5.7000000000000003e-5

    1. Initial program 51.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.7000000000000003e-5 < ky < 2.5e-176

    1. Initial program 68.5%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt50.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{ky \cdot \left|th\right|}{\sin kx}} \]
    10. Step-by-step derivation
      1. associate-/l*26.9%

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

      \[\leadsto \color{blue}{\frac{ky}{\frac{\sin kx}{\left|th\right|}}} \]
    12. Step-by-step derivation
      1. clear-num26.9%

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\left|th\right|}{\sin kx}}}} \cdot ky \]
      4. remove-double-div26.9%

        \[\leadsto \color{blue}{\frac{\left|th\right|}{\sin kx}} \cdot ky \]
      5. add-sqr-sqrt15.6%

        \[\leadsto \frac{\left|\color{blue}{\sqrt{th} \cdot \sqrt{th}}\right|}{\sin kx} \cdot ky \]
      6. fabs-sqr15.6%

        \[\leadsto \frac{\color{blue}{\sqrt{th} \cdot \sqrt{th}}}{\sin kx} \cdot ky \]
      7. add-sqr-sqrt29.9%

        \[\leadsto \frac{\color{blue}{th}}{\sin kx} \cdot ky \]
    13. Applied egg-rr29.9%

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

    if 2.5e-176 < ky

    1. Initial program 52.6%

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

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

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

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

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

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

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

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

Alternative 16: 38.1% accurate, 6.5× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < -1.14e-41 or 2.59999999999999992e-176 < ky

    1. Initial program 52.5%

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

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

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

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

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

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

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

    if -1.14e-41 < ky < 2.59999999999999992e-176

    1. Initial program 69.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt50.2%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{ky \cdot \left|th\right|}{\sin kx}} \]
    10. Step-by-step derivation
      1. associate-/l*28.5%

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

      \[\leadsto \color{blue}{\frac{ky}{\frac{\sin kx}{\left|th\right|}}} \]
    12. Step-by-step derivation
      1. clear-num28.5%

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

        \[\leadsto \color{blue}{\frac{1}{\frac{\sin kx}{\left|th\right|}} \cdot ky} \]
      3. clear-num28.5%

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\left|th\right|}{\sin kx}}}} \cdot ky \]
      4. remove-double-div28.5%

        \[\leadsto \color{blue}{\frac{\left|th\right|}{\sin kx}} \cdot ky \]
      5. add-sqr-sqrt16.6%

        \[\leadsto \frac{\left|\color{blue}{\sqrt{th} \cdot \sqrt{th}}\right|}{\sin kx} \cdot ky \]
      6. fabs-sqr16.6%

        \[\leadsto \frac{\color{blue}{\sqrt{th} \cdot \sqrt{th}}}{\sin kx} \cdot ky \]
      7. add-sqr-sqrt31.7%

        \[\leadsto \frac{\color{blue}{th}}{\sin kx} \cdot ky \]
    13. Applied egg-rr31.7%

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

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

Alternative 17: 37.1% accurate, 6.7× speedup?

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

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

\mathbf{elif}\;ky \leq 2.95 \cdot 10^{-157}:\\
\;\;\;\;\frac{ky}{0.16666666666666666 \cdot \left(th \cdot kx\right) + \frac{kx}{th}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < -1.14999999999999998e-36 or 2.9500000000000001e-157 < ky

    1. Initial program 52.0%

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

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

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

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

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

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

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

    if -1.14999999999999998e-36 < ky < 2.9500000000000001e-157

    1. Initial program 69.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{ky}{\color{blue}{0.16666666666666666 \cdot \left(kx \cdot th\right) + \frac{kx}{th}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification41.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq -1.15 \cdot 10^{-36}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 2.95 \cdot 10^{-157}:\\ \;\;\;\;\frac{ky}{0.16666666666666666 \cdot \left(th \cdot kx\right) + \frac{kx}{th}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]

Alternative 18: 27.8% accurate, 46.9× speedup?

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

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

\mathbf{elif}\;ky \leq 7.5 \cdot 10^{-155}:\\
\;\;\;\;\frac{ky}{0.16666666666666666 \cdot \left(th \cdot kx\right) + \frac{kx}{th}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < -0.819999999999999951 or 7.5000000000000006e-155 < ky

    1. Initial program 51.5%

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

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

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

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

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

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

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

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

    if -0.819999999999999951 < ky < 7.5000000000000006e-155

    1. Initial program 69.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{ky}{\color{blue}{0.16666666666666666 \cdot \left(kx \cdot th\right) + \frac{kx}{th}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification31.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq -0.82:\\ \;\;\;\;th\\ \mathbf{elif}\;ky \leq 7.5 \cdot 10^{-155}:\\ \;\;\;\;\frac{ky}{0.16666666666666666 \cdot \left(th \cdot kx\right) + \frac{kx}{th}}\\ \mathbf{else}:\\ \;\;\;\;th\\ \end{array} \]

Alternative 19: 27.7% accurate, 77.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < -5.49999999999999967e-28 or 7.30000000000000033e-155 < ky

    1. Initial program 52.0%

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

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

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

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

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

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

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

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

    if -5.49999999999999967e-28 < ky < 7.30000000000000033e-155

    1. Initial program 69.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{ky}{\frac{kx}{th}}} \]
    10. Simplified25.6%

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

        \[\leadsto \color{blue}{\frac{ky}{kx} \cdot th} \]
    12. Applied egg-rr25.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq -5.5 \cdot 10^{-28}:\\ \;\;\;\;th\\ \mathbf{elif}\;ky \leq 7.3 \cdot 10^{-155}:\\ \;\;\;\;th \cdot \frac{ky}{kx}\\ \mathbf{else}:\\ \;\;\;\;th\\ \end{array} \]

Alternative 20: 19.6% accurate, 709.0× speedup?

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{th} \]
  6. Final simplification24.5%

    \[\leadsto th \]

Reproduce

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