Toniolo and Linder, Equation (3b), real

Percentage Accurate: 93.9% → 99.7%
Time: 13.2s
Alternatives: 13
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 13 alternatives:

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

Initial Program: 93.9% accurate, 1.0× speedup?

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

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

Alternative 1: 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 93.8%

    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. *-un-lft-identity93.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 56.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin kx \leq -0.012:\\ \;\;\;\;\frac{1}{\frac{\sin ky}{\sin ky \cdot \sin th}}\\ \mathbf{elif}\;\sin kx \leq 1.8 \cdot 10^{-125} \lor \neg \left(\sin kx \leq 7.8 \cdot 10^{-81}\right) \land \sin kx \leq 8.5 \cdot 10^{-25}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\left|\sin ky\right|}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (if (<= (sin kx) -0.012)
   (/ 1.0 (/ (sin ky) (* (sin ky) (sin th))))
   (if (or (<= (sin kx) 1.8e-125)
           (and (not (<= (sin kx) 7.8e-81)) (<= (sin kx) 8.5e-25)))
     (* (sin ky) (/ (sin th) (fabs (sin ky))))
     (* (sin th) (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
	double tmp;
	if (sin(kx) <= -0.012) {
		tmp = 1.0 / (sin(ky) / (sin(ky) * sin(th)));
	} else if ((sin(kx) <= 1.8e-125) || (!(sin(kx) <= 7.8e-81) && (sin(kx) <= 8.5e-25))) {
		tmp = sin(ky) * (sin(th) / fabs(sin(ky)));
	} else {
		tmp = sin(th) * (sin(ky) / sin(kx));
	}
	return tmp;
}
real(8) function code(kx, ky, th)
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    real(8) :: tmp
    if (sin(kx) <= (-0.012d0)) then
        tmp = 1.0d0 / (sin(ky) / (sin(ky) * sin(th)))
    else if ((sin(kx) <= 1.8d-125) .or. (.not. (sin(kx) <= 7.8d-81)) .and. (sin(kx) <= 8.5d-25)) then
        tmp = sin(ky) * (sin(th) / abs(sin(ky)))
    else
        tmp = sin(th) * (sin(ky) / sin(kx))
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double tmp;
	if (Math.sin(kx) <= -0.012) {
		tmp = 1.0 / (Math.sin(ky) / (Math.sin(ky) * Math.sin(th)));
	} else if ((Math.sin(kx) <= 1.8e-125) || (!(Math.sin(kx) <= 7.8e-81) && (Math.sin(kx) <= 8.5e-25))) {
		tmp = Math.sin(ky) * (Math.sin(th) / Math.abs(Math.sin(ky)));
	} else {
		tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
	}
	return tmp;
}
def code(kx, ky, th):
	tmp = 0
	if math.sin(kx) <= -0.012:
		tmp = 1.0 / (math.sin(ky) / (math.sin(ky) * math.sin(th)))
	elif (math.sin(kx) <= 1.8e-125) or (not (math.sin(kx) <= 7.8e-81) and (math.sin(kx) <= 8.5e-25)):
		tmp = math.sin(ky) * (math.sin(th) / math.fabs(math.sin(ky)))
	else:
		tmp = math.sin(th) * (math.sin(ky) / math.sin(kx))
	return tmp
function code(kx, ky, th)
	tmp = 0.0
	if (sin(kx) <= -0.012)
		tmp = Float64(1.0 / Float64(sin(ky) / Float64(sin(ky) * sin(th))));
	elseif ((sin(kx) <= 1.8e-125) || (!(sin(kx) <= 7.8e-81) && (sin(kx) <= 8.5e-25)))
		tmp = Float64(sin(ky) * Float64(sin(th) / abs(sin(ky))));
	else
		tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx)));
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	tmp = 0.0;
	if (sin(kx) <= -0.012)
		tmp = 1.0 / (sin(ky) / (sin(ky) * sin(th)));
	elseif ((sin(kx) <= 1.8e-125) || (~((sin(kx) <= 7.8e-81)) && (sin(kx) <= 8.5e-25)))
		tmp = sin(ky) * (sin(th) / abs(sin(ky)));
	else
		tmp = sin(th) * (sin(ky) / sin(kx));
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.012], N[(1.0 / N[(N[Sin[ky], $MachinePrecision] / N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[Sin[kx], $MachinePrecision], 1.8e-125], And[N[Not[LessEqual[N[Sin[kx], $MachinePrecision], 7.8e-81]], $MachinePrecision], LessEqual[N[Sin[kx], $MachinePrecision], 8.5e-25]]], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.012:\\
\;\;\;\;\frac{1}{\frac{\sin ky}{\sin ky \cdot \sin th}}\\

\mathbf{elif}\;\sin kx \leq 1.8 \cdot 10^{-125} \lor \neg \left(\sin kx \leq 7.8 \cdot 10^{-81}\right) \land \sin kx \leq 8.5 \cdot 10^{-25}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\left|\sin ky\right|}\\

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


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

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sin ky}} \]
      2. clear-num20.0%

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

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

    if -0.012 < (sin.f64 kx) < 1.8000000000000001e-125 or 7.7999999999999997e-81 < (sin.f64 kx) < 8.49999999999999981e-25

    1. Initial program 86.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sin ky \cdot \frac{\sin th}{\color{blue}{\sqrt{\sin ky \cdot \sin ky}}} \]
      3. sqr-sin-a54.4%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{\color{blue}{0.5 - 0.5 \cdot \cos \left(2 \cdot ky\right)}}} \]
      4. metadata-eval54.4%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{0.5 - \color{blue}{\frac{1}{2}} \cdot \cos \left(2 \cdot ky\right)}} \]
      5. *-commutative54.4%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{0.5 - \frac{1}{2} \cdot \cos \color{blue}{\left(ky \cdot 2\right)}}} \]
      6. associate-/r/54.2%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{0.5 - \color{blue}{\frac{1}{\frac{2}{\cos \left(ky \cdot 2\right)}}}}} \]
      7. clear-num54.4%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{0.5 - \color{blue}{\frac{\cos \left(ky \cdot 2\right)}{2}}}} \]
      8. add-sqr-sqrt54.4%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{\color{blue}{\sqrt{0.5 - \frac{\cos \left(ky \cdot 2\right)}{2}} \cdot \sqrt{0.5 - \frac{\cos \left(ky \cdot 2\right)}{2}}}}} \]
      9. rem-sqrt-square54.4%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\color{blue}{\left|\sqrt{0.5 - \frac{\cos \left(ky \cdot 2\right)}{2}}\right|}} \]
      10. clear-num54.2%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\left|\sqrt{0.5 - \color{blue}{\frac{1}{\frac{2}{\cos \left(ky \cdot 2\right)}}}}\right|} \]
      11. associate-/r/54.4%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\left|\sqrt{0.5 - \color{blue}{\frac{1}{2} \cdot \cos \left(ky \cdot 2\right)}}\right|} \]
      12. metadata-eval54.4%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\left|\sqrt{0.5 - \color{blue}{0.5} \cdot \cos \left(ky \cdot 2\right)}\right|} \]
      13. *-commutative54.4%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\left|\sqrt{0.5 - 0.5 \cdot \cos \color{blue}{\left(2 \cdot ky\right)}}\right|} \]
      14. sqr-sin-a74.9%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\left|\sqrt{\color{blue}{\sin ky \cdot \sin ky}}\right|} \]
      15. sqrt-unprod46.1%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\left|\color{blue}{\sqrt{\sin ky} \cdot \sqrt{\sin ky}}\right|} \]
      16. add-sqr-sqrt84.2%

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

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

    if 1.8000000000000001e-125 < (sin.f64 kx) < 7.7999999999999997e-81 or 8.49999999999999981e-25 < (sin.f64 kx)

    1. Initial program 99.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sin kx \leq -0.012:\\ \;\;\;\;\frac{1}{\frac{\sin ky}{\sin ky \cdot \sin th}}\\ \mathbf{elif}\;\sin kx \leq 1.8 \cdot 10^{-125} \lor \neg \left(\sin kx \leq 7.8 \cdot 10^{-81}\right) \land \sin kx \leq 8.5 \cdot 10^{-25}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\left|\sin ky\right|}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 40.3% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.012:\\
\;\;\;\;\frac{1}{\frac{\sin ky}{\sin ky \cdot \sin th}}\\

\mathbf{elif}\;\sin kx \leq 1.8 \cdot 10^{-129}:\\
\;\;\;\;\sin th\\

\mathbf{elif}\;\sin kx \leq 1.6 \cdot 10^{-80} \lor \neg \left(\sin kx \leq 6 \cdot 10^{-26}\right):\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\

\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\


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

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sin ky}} \]
      2. clear-num20.0%

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

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

    if -0.012 < (sin.f64 kx) < 1.8e-129

    1. Initial program 85.1%

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

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

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

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

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

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

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

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

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

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

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

    if 1.8e-129 < (sin.f64 kx) < 1.5999999999999999e-80 or 6.00000000000000023e-26 < (sin.f64 kx)

    1. Initial program 99.5%

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

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

    if 1.5999999999999999e-80 < (sin.f64 kx) < 6.00000000000000023e-26

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{{\left(\sin ky \cdot \frac{\sin th}{\sin ky}\right)}^{2}}} \]
      4. associate-*r/35.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\sin th \cdot \frac{\sin ky}{\sin ky}\right|} \]
      3. *-inverses51.6%

        \[\leadsto \left|\sin th \cdot \color{blue}{1}\right| \]
      4. *-rgt-identity51.6%

        \[\leadsto \left|\color{blue}{\sin th}\right| \]
    9. Simplified51.6%

      \[\leadsto \color{blue}{\left|\sin th\right|} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification42.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sin kx \leq -0.012:\\ \;\;\;\;\frac{1}{\frac{\sin ky}{\sin ky \cdot \sin th}}\\ \mathbf{elif}\;\sin kx \leq 1.8 \cdot 10^{-129}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;\sin kx \leq 1.6 \cdot 10^{-80} \lor \neg \left(\sin kx \leq 6 \cdot 10^{-26}\right):\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\left|\sin th\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 99.6% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 66.3% accurate, 1.7× speedup?

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

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

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


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

    1. Initial program 91.6%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity91.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.00309999999999999989 < ky

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sin ky \cdot \frac{\sin th}{\color{blue}{\sqrt{\sin ky \cdot \sin ky}}} \]
      3. sqr-sin-a54.0%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{\color{blue}{0.5 - 0.5 \cdot \cos \left(2 \cdot ky\right)}}} \]
      4. metadata-eval54.0%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{0.5 - \color{blue}{\frac{1}{2}} \cdot \cos \left(2 \cdot ky\right)}} \]
      5. *-commutative54.0%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{0.5 - \frac{1}{2} \cdot \cos \color{blue}{\left(ky \cdot 2\right)}}} \]
      6. associate-/r/54.0%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{0.5 - \color{blue}{\frac{1}{\frac{2}{\cos \left(ky \cdot 2\right)}}}}} \]
      7. clear-num54.0%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{0.5 - \color{blue}{\frac{\cos \left(ky \cdot 2\right)}{2}}}} \]
      8. add-sqr-sqrt54.0%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\sqrt{\color{blue}{\sqrt{0.5 - \frac{\cos \left(ky \cdot 2\right)}{2}} \cdot \sqrt{0.5 - \frac{\cos \left(ky \cdot 2\right)}{2}}}}} \]
      9. rem-sqrt-square54.0%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\color{blue}{\left|\sqrt{0.5 - \frac{\cos \left(ky \cdot 2\right)}{2}}\right|}} \]
      10. clear-num54.0%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\left|\sqrt{0.5 - \color{blue}{\frac{1}{\frac{2}{\cos \left(ky \cdot 2\right)}}}}\right|} \]
      11. associate-/r/54.0%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\left|\sqrt{0.5 - \color{blue}{\frac{1}{2} \cdot \cos \left(ky \cdot 2\right)}}\right|} \]
      12. metadata-eval54.0%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\left|\sqrt{0.5 - \color{blue}{0.5} \cdot \cos \left(ky \cdot 2\right)}\right|} \]
      13. *-commutative54.0%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\left|\sqrt{0.5 - 0.5 \cdot \cos \color{blue}{\left(2 \cdot ky\right)}}\right|} \]
      14. sqr-sin-a54.2%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\left|\sqrt{\color{blue}{\sin ky \cdot \sin ky}}\right|} \]
      15. sqrt-unprod29.3%

        \[\leadsto \sin ky \cdot \frac{\sin th}{\left|\color{blue}{\sqrt{\sin ky} \cdot \sqrt{\sin ky}}\right|} \]
      16. add-sqr-sqrt54.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;ky \leq 0.0031:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\left|\sin ky\right|}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 31.8% accurate, 2.2× speedup?

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

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

\mathbf{elif}\;kx \leq 3.6 \cdot 10^{-80} \lor \neg \left(kx \leq 1.7 \cdot 10^{-24}\right):\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\

\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if kx < 1.29999999999999998e-131

    1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

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

    if 1.29999999999999998e-131 < kx < 3.6e-80 or 1.69999999999999996e-24 < kx

    1. Initial program 99.4%

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

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

    if 3.6e-80 < kx < 1.69999999999999996e-24

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{{\left(\sin ky \cdot \frac{\sin th}{\sin ky}\right)}^{2}}} \]
      4. associate-*r/35.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\sin th \cdot \frac{\sin ky}{\sin ky}\right|} \]
      3. *-inverses51.6%

        \[\leadsto \left|\sin th \cdot \color{blue}{1}\right| \]
      4. *-rgt-identity51.6%

        \[\leadsto \left|\color{blue}{\sin th}\right| \]
    9. Simplified51.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 1.3 \cdot 10^{-131}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;kx \leq 3.6 \cdot 10^{-80} \lor \neg \left(kx \leq 1.7 \cdot 10^{-24}\right):\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\left|\sin th\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 31.9% accurate, 2.2× speedup?

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

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

\mathbf{elif}\;kx \leq 8.5 \cdot 10^{-81} \lor \neg \left(kx \leq 7.6 \cdot 10^{-26}\right):\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\

\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if kx < 1.8e-129

    1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

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

    if 1.8e-129 < kx < 8.5000000000000001e-81 or 7.60000000000000029e-26 < kx

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

    if 8.5000000000000001e-81 < kx < 7.60000000000000029e-26

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{{\left(\sin ky \cdot \frac{\sin th}{\sin ky}\right)}^{2}}} \]
      4. associate-*r/35.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\sin th \cdot \frac{\sin ky}{\sin ky}\right|} \]
      3. *-inverses51.6%

        \[\leadsto \left|\sin th \cdot \color{blue}{1}\right| \]
      4. *-rgt-identity51.6%

        \[\leadsto \left|\color{blue}{\sin th}\right| \]
    9. Simplified51.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 1.8 \cdot 10^{-129}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;kx \leq 8.5 \cdot 10^{-81} \lor \neg \left(kx \leq 7.6 \cdot 10^{-26}\right):\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\left|\sin th\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 31.1% accurate, 2.2× speedup?

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

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

\mathbf{elif}\;kx \leq 1.6 \cdot 10^{-80}:\\
\;\;\;\;\sin th \cdot t\_1\\

\mathbf{elif}\;kx \leq 2.5 \cdot 10^{-25}:\\
\;\;\;\;\left|\sin th\right|\\

\mathbf{else}:\\
\;\;\;\;\sin th \cdot \mathsf{expm1}\left(t\_1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if kx < 1.30000000000000003e-125

    1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

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

    if 1.30000000000000003e-125 < kx < 1.5999999999999999e-80

    1. Initial program 100.0%

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

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

    if 1.5999999999999999e-80 < kx < 2.49999999999999981e-25

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{{\left(\sin ky \cdot \frac{\sin th}{\sin ky}\right)}^{2}}} \]
      4. associate-*r/35.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\sin th \cdot \frac{\sin ky}{\sin ky}\right|} \]
      3. *-inverses51.6%

        \[\leadsto \left|\sin th \cdot \color{blue}{1}\right| \]
      4. *-rgt-identity51.6%

        \[\leadsto \left|\color{blue}{\sin th}\right| \]
    9. Simplified51.6%

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

    if 2.49999999999999981e-25 < kx

    1. Initial program 99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 1.3 \cdot 10^{-125}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;kx \leq 1.6 \cdot 10^{-80}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{elif}\;kx \leq 2.5 \cdot 10^{-25}:\\ \;\;\;\;\left|\sin th\right|\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \mathsf{expm1}\left(\frac{ky}{\sin kx}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 30.7% accurate, 3.2× speedup?

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

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

\mathbf{elif}\;kx \leq 2.9 \cdot 10^{-80} \lor \neg \left(kx \leq 4.5 \cdot 10^{-26}\right):\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\

\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if kx < 1.00000000000000001e-125

    1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

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

    if 1.00000000000000001e-125 < kx < 2.89999999999999998e-80 or 4.4999999999999999e-26 < kx

    1. Initial program 99.4%

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

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

    if 2.89999999999999998e-80 < kx < 4.4999999999999999e-26

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{{\left(\sin ky \cdot \frac{\sin th}{\sin ky}\right)}^{2}}} \]
      4. associate-*r/35.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\sin th \cdot \frac{\sin ky}{\sin ky}\right|} \]
      3. *-inverses51.6%

        \[\leadsto \left|\sin th \cdot \color{blue}{1}\right| \]
      4. *-rgt-identity51.6%

        \[\leadsto \left|\color{blue}{\sin th}\right| \]
    9. Simplified51.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 10^{-125}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;kx \leq 2.9 \cdot 10^{-80} \lor \neg \left(kx \leq 4.5 \cdot 10^{-26}\right):\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\left|\sin th\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 30.7% accurate, 3.2× speedup?

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

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

\mathbf{elif}\;kx \leq 4.5 \cdot 10^{-80} \lor \neg \left(kx \leq 1.85 \cdot 10^{-25}\right):\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\

\mathbf{else}:\\
\;\;\;\;\left|\sin th\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if kx < 1.8000000000000001e-125

    1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

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

    if 1.8000000000000001e-125 < kx < 4.5000000000000003e-80 or 1.85000000000000004e-25 < kx

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.5000000000000003e-80 < kx < 1.85000000000000004e-25

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{{\left(\sin ky \cdot \frac{\sin th}{\sin ky}\right)}^{2}}} \]
      4. associate-*r/35.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\sin th \cdot \frac{\sin ky}{\sin ky}\right|} \]
      3. *-inverses51.6%

        \[\leadsto \left|\sin th \cdot \color{blue}{1}\right| \]
      4. *-rgt-identity51.6%

        \[\leadsto \left|\color{blue}{\sin th}\right| \]
    9. Simplified51.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \leq 1.8 \cdot 10^{-125}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;kx \leq 4.5 \cdot 10^{-80} \lor \neg \left(kx \leq 1.85 \cdot 10^{-25}\right):\\ \;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\left|\sin th\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 23.6% accurate, 3.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;ky \leq 1.15 \cdot 10^{-188}:\\
\;\;\;\;\sqrt{{th}^{2}}\\

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


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

    1. Initial program 92.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{{\left(\sin ky \cdot \frac{\sin th}{\sin ky}\right)}^{2}}} \]
      4. associate-*r/30.2%

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

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

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

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

        \[\leadsto \sqrt{{\left(\sin th \cdot \color{blue}{1}\right)}^{2}} \]
      2. *-commutative27.6%

        \[\leadsto \sqrt{{\color{blue}{\left(1 \cdot \sin th\right)}}^{2}} \]
    9. Simplified27.6%

      \[\leadsto \color{blue}{\sqrt{{\left(1 \cdot \sin th\right)}^{2}}} \]
    10. Taylor expanded in th around 0 19.0%

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

    if 1.15e-188 < ky

    1. Initial program 95.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 23.8% accurate, 7.0× speedup?

\[\begin{array}{l} \\ \sin th \end{array} \]
(FPCore (kx ky th) :precision binary64 (sin th))
double code(double kx, double ky, double th) {
	return 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(th)
end function
public static double code(double kx, double ky, double th) {
	return Math.sin(th);
}
def code(kx, ky, th):
	return math.sin(th)
function code(kx, ky, th)
	return sin(th)
end
function tmp = code(kx, ky, th)
	tmp = sin(th);
end
code[kx_, ky_, th_] := N[Sin[th], $MachinePrecision]
\begin{array}{l}

\\
\sin th
\end{array}
Derivation
  1. Initial program 93.8%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sin th} \]
  6. Add Preprocessing

Alternative 13: 13.6% accurate, 709.0× speedup?

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

\\
th
\end{array}
Derivation
  1. Initial program 93.8%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{th} \]
  7. Add Preprocessing

Reproduce

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