Toniolo and Linder, Equation (3b), real

Percentage Accurate: 94.1% → 99.7%
Time: 23.5s
Alternatives: 20
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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: 94.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

Alternative 2: 58.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \sin th \cdot \frac{ky}{\left|\sin kx\right|}\\ t_2 := \frac{\sin ky}{\frac{\mathsf{hypot}\left(kx, \sin ky\right)}{th}}\\ \mathbf{if}\;\sin ky \leq -2 \cdot 10^{-22}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\sin ky \leq -5 \cdot 10^{-173}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\sin ky \leq -5 \cdot 10^{-190}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-35}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (* (sin th) (/ ky (fabs (sin kx)))))
        (t_2 (/ (sin ky) (/ (hypot kx (sin ky)) th))))
   (if (<= (sin ky) -2e-22)
     t_2
     (if (<= (sin ky) -5e-173)
       t_1
       (if (<= (sin ky) -5e-190) t_2 (if (<= (sin ky) 5e-35) t_1 (sin th)))))))
double code(double kx, double ky, double th) {
	double t_1 = sin(th) * (ky / fabs(sin(kx)));
	double t_2 = sin(ky) / (hypot(kx, sin(ky)) / th);
	double tmp;
	if (sin(ky) <= -2e-22) {
		tmp = t_2;
	} else if (sin(ky) <= -5e-173) {
		tmp = t_1;
	} else if (sin(ky) <= -5e-190) {
		tmp = t_2;
	} else if (sin(ky) <= 5e-35) {
		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) * (ky / Math.abs(Math.sin(kx)));
	double t_2 = Math.sin(ky) / (Math.hypot(kx, Math.sin(ky)) / th);
	double tmp;
	if (Math.sin(ky) <= -2e-22) {
		tmp = t_2;
	} else if (Math.sin(ky) <= -5e-173) {
		tmp = t_1;
	} else if (Math.sin(ky) <= -5e-190) {
		tmp = t_2;
	} else if (Math.sin(ky) <= 5e-35) {
		tmp = t_1;
	} else {
		tmp = Math.sin(th);
	}
	return tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(th) * (ky / math.fabs(math.sin(kx)))
	t_2 = math.sin(ky) / (math.hypot(kx, math.sin(ky)) / th)
	tmp = 0
	if math.sin(ky) <= -2e-22:
		tmp = t_2
	elif math.sin(ky) <= -5e-173:
		tmp = t_1
	elif math.sin(ky) <= -5e-190:
		tmp = t_2
	elif math.sin(ky) <= 5e-35:
		tmp = t_1
	else:
		tmp = math.sin(th)
	return tmp
function code(kx, ky, th)
	t_1 = Float64(sin(th) * Float64(ky / abs(sin(kx))))
	t_2 = Float64(sin(ky) / Float64(hypot(kx, sin(ky)) / th))
	tmp = 0.0
	if (sin(ky) <= -2e-22)
		tmp = t_2;
	elseif (sin(ky) <= -5e-173)
		tmp = t_1;
	elseif (sin(ky) <= -5e-190)
		tmp = t_2;
	elseif (sin(ky) <= 5e-35)
		tmp = t_1;
	else
		tmp = sin(th);
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(th) * (ky / abs(sin(kx)));
	t_2 = sin(ky) / (hypot(kx, sin(ky)) / th);
	tmp = 0.0;
	if (sin(ky) <= -2e-22)
		tmp = t_2;
	elseif (sin(ky) <= -5e-173)
		tmp = t_1;
	elseif (sin(ky) <= -5e-190)
		tmp = t_2;
	elseif (sin(ky) <= 5e-35)
		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[(ky / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[kx ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], -2e-22], t$95$2, If[LessEqual[N[Sin[ky], $MachinePrecision], -5e-173], t$95$1, If[LessEqual[N[Sin[ky], $MachinePrecision], -5e-190], t$95$2, If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-35], t$95$1, N[Sin[th], $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;\sin ky \leq -5 \cdot 10^{-173}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\sin ky \leq -5 \cdot 10^{-190}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-35}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (sin.f64 ky) < -2.0000000000000001e-22 or -5.0000000000000002e-173 < (sin.f64 ky) < -5.00000000000000034e-190

    1. Initial program 93.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-22 < (sin.f64 ky) < -5.0000000000000002e-173 or -5.00000000000000034e-190 < (sin.f64 ky) < 4.99999999999999964e-35

    1. Initial program 86.2%

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999964e-35 < (sin.f64 ky)

    1. Initial program 99.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sin ky \leq -2 \cdot 10^{-22}:\\ \;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(kx, \sin ky\right)}{th}}\\ \mathbf{elif}\;\sin ky \leq -5 \cdot 10^{-173}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\left|\sin kx\right|}\\ \mathbf{elif}\;\sin ky \leq -5 \cdot 10^{-190}:\\ \;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(kx, \sin ky\right)}{th}}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-35}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\left|\sin kx\right|}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]

Alternative 3: 58.6% accurate, 1.0× speedup?

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

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

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

\mathbf{elif}\;\sin ky \leq -5 \cdot 10^{-190}:\\
\;\;\;\;t_2\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (sin.f64 ky) < -0.20000000000000001 or -5.0000000000000002e-173 < (sin.f64 ky) < -5.00000000000000034e-190

    1. Initial program 92.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.20000000000000001 < (sin.f64 ky) < -5.0000000000000002e-173

    1. Initial program 99.5%

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

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

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

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

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

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

    if -5.00000000000000034e-190 < (sin.f64 ky) < 4.99999999999999964e-35

    1. Initial program 82.3%

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999964e-35 < (sin.f64 ky)

    1. Initial program 99.7%

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

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

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

Alternative 4: 58.6% accurate, 1.0× speedup?

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

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

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

\mathbf{elif}\;\sin ky \leq -5 \cdot 10^{-190}:\\
\;\;\;\;t_2\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (sin.f64 ky) < -0.20000000000000001 or -5.0000000000000002e-173 < (sin.f64 ky) < -5.00000000000000034e-190

    1. Initial program 92.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.20000000000000001 < (sin.f64 ky) < -5.0000000000000002e-173

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{ky}{\color{blue}{\left|\sin kx\right|}} \cdot \sin th \]
    6. Applied egg-rr59.9%

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

    if -5.00000000000000034e-190 < (sin.f64 ky) < 4.99999999999999964e-35

    1. Initial program 82.3%

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999964e-35 < (sin.f64 ky)

    1. Initial program 99.7%

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

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

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

Alternative 5: 71.5% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -0.01 \lor \neg \left(\sin th \leq 0.002\right):\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\

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


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

    1. Initial program 94.7%

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

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

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

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

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

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

    if -0.0100000000000000002 < (sin.f64 th) < 2e-3

    1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 54.2% accurate, 1.4× speedup?

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

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

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

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


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.050000000000000003 < (sin.f64 ky) < 4.99999999999999964e-35

    1. Initial program 83.5%

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999964e-35 < (sin.f64 ky)

    1. Initial program 99.7%

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

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

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

Alternative 7: 66.5% accurate, 1.7× speedup?

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

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

\mathbf{elif}\;kx \leq 1.5 \cdot 10^{+103}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;kx \leq 1.3 \cdot 10^{+141}:\\
\;\;\;\;\frac{\sin ky \cdot \sin th}{t_2}\\

\mathbf{elif}\;kx \leq 2.7 \cdot 10^{+235}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if kx < 7e4

    1. Initial program 89.5%

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

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

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

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

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

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

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

    if 7e4 < kx < 1.5e103 or 1.3e141 < kx < 2.6999999999999997e235

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.5e103 < kx < 1.3e141

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.6999999999999997e235 < kx

    1. Initial program 99.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 70000:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{elif}\;kx \leq 1.5 \cdot 10^{+103}:\\ \;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{elif}\;kx \leq 1.3 \cdot 10^{+141}:\\ \;\;\;\;\frac{\sin ky \cdot \sin th}{\left|\sin kx\right|}\\ \mathbf{elif}\;kx \leq 2.7 \cdot 10^{+235}:\\ \;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\ \end{array} \]

Alternative 8: 66.5% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\ t_2 := \left|\sin kx\right|\\ \mathbf{if}\;kx \leq 70000:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{elif}\;kx \leq 8.8 \cdot 10^{+102}:\\ \;\;\;\;\frac{\sin ky}{t_1} \cdot th\\ \mathbf{elif}\;kx \leq 3.4 \cdot 10^{+141}:\\ \;\;\;\;\frac{\sin ky \cdot \sin th}{t_2}\\ \mathbf{elif}\;kx \leq 2.4 \cdot 10^{+235}:\\ \;\;\;\;\sin ky \cdot \frac{th}{t_1}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{t_2}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (hypot (sin ky) (sin kx))) (t_2 (fabs (sin kx))))
   (if (<= kx 70000.0)
     (* (sin th) (/ (sin ky) (hypot (sin ky) kx)))
     (if (<= kx 8.8e+102)
       (* (/ (sin ky) t_1) th)
       (if (<= kx 3.4e+141)
         (/ (* (sin ky) (sin th)) t_2)
         (if (<= kx 2.4e+235)
           (* (sin ky) (/ th t_1))
           (* (sin th) (/ (sin ky) t_2))))))))
double code(double kx, double ky, double th) {
	double t_1 = hypot(sin(ky), sin(kx));
	double t_2 = fabs(sin(kx));
	double tmp;
	if (kx <= 70000.0) {
		tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx));
	} else if (kx <= 8.8e+102) {
		tmp = (sin(ky) / t_1) * th;
	} else if (kx <= 3.4e+141) {
		tmp = (sin(ky) * sin(th)) / t_2;
	} else if (kx <= 2.4e+235) {
		tmp = sin(ky) * (th / t_1);
	} else {
		tmp = sin(th) * (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.abs(Math.sin(kx));
	double tmp;
	if (kx <= 70000.0) {
		tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), kx));
	} else if (kx <= 8.8e+102) {
		tmp = (Math.sin(ky) / t_1) * th;
	} else if (kx <= 3.4e+141) {
		tmp = (Math.sin(ky) * Math.sin(th)) / t_2;
	} else if (kx <= 2.4e+235) {
		tmp = Math.sin(ky) * (th / t_1);
	} else {
		tmp = Math.sin(th) * (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.fabs(math.sin(kx))
	tmp = 0
	if kx <= 70000.0:
		tmp = math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), kx))
	elif kx <= 8.8e+102:
		tmp = (math.sin(ky) / t_1) * th
	elif kx <= 3.4e+141:
		tmp = (math.sin(ky) * math.sin(th)) / t_2
	elif kx <= 2.4e+235:
		tmp = math.sin(ky) * (th / t_1)
	else:
		tmp = math.sin(th) * (math.sin(ky) / t_2)
	return tmp
function code(kx, ky, th)
	t_1 = hypot(sin(ky), sin(kx))
	t_2 = abs(sin(kx))
	tmp = 0.0
	if (kx <= 70000.0)
		tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), kx)));
	elseif (kx <= 8.8e+102)
		tmp = Float64(Float64(sin(ky) / t_1) * th);
	elseif (kx <= 3.4e+141)
		tmp = Float64(Float64(sin(ky) * sin(th)) / t_2);
	elseif (kx <= 2.4e+235)
		tmp = Float64(sin(ky) * Float64(th / t_1));
	else
		tmp = Float64(sin(th) * Float64(sin(ky) / t_2));
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	t_1 = hypot(sin(ky), sin(kx));
	t_2 = abs(sin(kx));
	tmp = 0.0;
	if (kx <= 70000.0)
		tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx));
	elseif (kx <= 8.8e+102)
		tmp = (sin(ky) / t_1) * th;
	elseif (kx <= 3.4e+141)
		tmp = (sin(ky) * sin(th)) / t_2;
	elseif (kx <= 2.4e+235)
		tmp = sin(ky) * (th / t_1);
	else
		tmp = sin(th) * (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[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[kx, 70000.0], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[kx, 8.8e+102], N[(N[(N[Sin[ky], $MachinePrecision] / t$95$1), $MachinePrecision] * th), $MachinePrecision], If[LessEqual[kx, 3.4e+141], N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[kx, 2.4e+235], N[(N[Sin[ky], $MachinePrecision] * N[(th / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;kx \leq 8.8 \cdot 10^{+102}:\\
\;\;\;\;\frac{\sin ky}{t_1} \cdot th\\

\mathbf{elif}\;kx \leq 3.4 \cdot 10^{+141}:\\
\;\;\;\;\frac{\sin ky \cdot \sin th}{t_2}\\

\mathbf{elif}\;kx \leq 2.4 \cdot 10^{+235}:\\
\;\;\;\;\sin ky \cdot \frac{th}{t_1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if kx < 7e4

    1. Initial program 89.5%

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

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

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

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

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

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

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

    if 7e4 < kx < 8.8000000000000003e102

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.8000000000000003e102 < kx < 3.3999999999999998e141

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.3999999999999998e141 < kx < 2.3999999999999999e235

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.3999999999999999e235 < kx

    1. Initial program 99.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 70000:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{elif}\;kx \leq 8.8 \cdot 10^{+102}:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\ \mathbf{elif}\;kx \leq 3.4 \cdot 10^{+141}:\\ \;\;\;\;\frac{\sin ky \cdot \sin th}{\left|\sin kx\right|}\\ \mathbf{elif}\;kx \leq 2.4 \cdot 10^{+235}:\\ \;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\ \end{array} \]

Alternative 9: 66.5% accurate, 1.7× speedup?

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

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

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

\mathbf{elif}\;kx \leq 5.4 \cdot 10^{+141}:\\
\;\;\;\;\frac{\sin ky \cdot \sin th}{t_1}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if kx < 7e4

    1. Initial program 89.5%

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

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

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

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

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

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

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

    if 7e4 < kx < 3.29999999999999999e102

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.29999999999999999e102 < kx < 5.4000000000000002e141

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.4000000000000002e141 < kx < 9.49999999999999966e235

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.49999999999999966e235 < kx

    1. Initial program 99.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 70000:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{elif}\;kx \leq 3.3 \cdot 10^{+102}:\\ \;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\ \mathbf{elif}\;kx \leq 5.4 \cdot 10^{+141}:\\ \;\;\;\;\frac{\sin ky \cdot \sin th}{\left|\sin kx\right|}\\ \mathbf{elif}\;kx \leq 9.5 \cdot 10^{+235}:\\ \;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\ \end{array} \]

Alternative 10: 66.6% accurate, 1.7× speedup?

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

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

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

\mathbf{elif}\;kx \leq 2.5 \cdot 10^{+144}:\\
\;\;\;\;\frac{\sin ky \cdot \sin th}{t_1}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if kx < 7e4

    1. Initial program 89.5%

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

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

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

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

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

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

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

    if 7e4 < kx < 6.60000000000000022e101

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.60000000000000022e101 < kx < 2.5e144

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.5e144 < kx < 4.4e235

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.4e235 < kx

    1. Initial program 99.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 70000:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\ \mathbf{elif}\;kx \leq 6.6 \cdot 10^{+101}:\\ \;\;\;\;\sin ky \cdot \frac{1}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\ \mathbf{elif}\;kx \leq 2.5 \cdot 10^{+144}:\\ \;\;\;\;\frac{\sin ky \cdot \sin th}{\left|\sin kx\right|}\\ \mathbf{elif}\;kx \leq 4.4 \cdot 10^{+235}:\\ \;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\ \end{array} \]

Alternative 11: 53.0% accurate, 1.7× speedup?

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

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

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


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

    1. Initial program 89.2%

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999964e-35 < (sin.f64 ky)

    1. Initial program 99.7%

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

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

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

Alternative 12: 39.5% accurate, 2.3× speedup?

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

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

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


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

    1. Initial program 89.1%

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

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

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

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

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

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

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

    if 1.00000000000000001e-35 < (sin.f64 ky)

    1. Initial program 99.7%

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

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

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

Alternative 13: 39.5% accurate, 2.3× speedup?

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

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

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


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

    1. Initial program 89.1%

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

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

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

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

    if 1.00000000000000001e-35 < (sin.f64 ky)

    1. Initial program 99.7%

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

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

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

Alternative 14: 39.5% accurate, 2.3× speedup?

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

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

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


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

    1. Initial program 89.1%

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

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

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

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

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

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

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

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

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

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

    if 1.00000000000000001e-35 < (sin.f64 ky)

    1. Initial program 99.7%

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

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

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

Alternative 15: 31.8% accurate, 3.4× speedup?

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

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

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


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

    1. Initial program 89.0%

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

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

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

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

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

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

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

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

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

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

    if 4e-52 < (sin.f64 ky)

    1. Initial program 99.7%

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

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

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

Alternative 16: 31.5% accurate, 6.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < -5200 or 2.3499999999999999e-51 < ky

    1. Initial program 99.7%

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

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

    if -5200 < ky < 2.3499999999999999e-51

    1. Initial program 82.6%

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

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

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

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

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

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

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

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

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

Alternative 17: 31.6% accurate, 6.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < -5200 or 2.4000000000000002e-52 < ky

    1. Initial program 99.7%

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

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

    if -5200 < ky < 2.4000000000000002e-52

    1. Initial program 82.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sin th \cdot 1}{kx}} \cdot ky \]
      6. *-rgt-identity42.6%

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

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

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

Alternative 18: 28.6% accurate, 6.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < -5200 or 1.15999999999999996e-55 < ky

    1. Initial program 99.7%

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

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

    if -5200 < ky < 1.15999999999999996e-55

    1. Initial program 82.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{ky}{\frac{kx}{th}}} \]
    8. Simplified35.0%

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

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

Alternative 19: 21.1% accurate, 77.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ky < -1.10000000000000005e-31 or 2.30000000000000002e-51 < ky

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.10000000000000005e-31 < ky < 2.30000000000000002e-51

    1. Initial program 82.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{ky}{\frac{kx}{th}}} \]
    8. Simplified35.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq -1.1 \cdot 10^{-31}:\\ \;\;\;\;th\\ \mathbf{elif}\;ky \leq 2.3 \cdot 10^{-51}:\\ \;\;\;\;\frac{ky}{\frac{kx}{th}}\\ \mathbf{else}:\\ \;\;\;\;th\\ \end{array} \]

Alternative 20: 13.5% 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 92.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{th} \]
  10. Final simplification13.4%

    \[\leadsto th \]

Reproduce

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