Toniolo and Linder, Equation (3b), real

Percentage Accurate: 93.7% → 96.7%
Time: 19.1s
Alternatives: 18
Speedup: 1.0×

Specification

?
\[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
(FPCore (kx ky th)
  :precision binary64
  (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2) (pow (sin ky) 2)))) (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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(kx, ky, th)
use fmin_fmax_functions
    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], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th

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 18 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.7% accurate, 1.0× speedup?

\[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
(FPCore (kx ky th)
  :precision binary64
  (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2) (pow (sin ky) 2)))) (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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(kx, ky, th)
use fmin_fmax_functions
    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], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th

Alternative 1: 96.7% accurate, 0.8× speedup?

\[\begin{array}{l} t_1 := \sin \left(\left|ky\right|\right)\\ \mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l} \mathbf{if}\;\left|ky\right| \leq \frac{3480865949723965}{4351082437154956072465106588077822995084026820419845514849846380137705962380101572519219218556758308199541387151331336317719177934050977705242787666055883587123865770683541250307916824576}:\\ \;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}} \cdot \sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1 (sin (fabs ky))))
  (*
   (copysign 1 ky)
   (if (<=
        (fabs ky)
        3480865949723965/4351082437154956072465106588077822995084026820419845514849846380137705962380101572519219218556758308199541387151331336317719177934050977705242787666055883587123865770683541250307916824576)
     (* (sin th) (/ (fabs ky) (fabs (sin kx))))
     (* (/ t_1 (sqrt (+ (pow (sin kx) 2) (pow t_1 2)))) (sin th))))))
double code(double kx, double ky, double th) {
	double t_1 = sin(fabs(ky));
	double tmp;
	if (fabs(ky) <= 8e-172) {
		tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
	} else {
		tmp = (t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)))) * sin(th);
	}
	return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sin(Math.abs(ky));
	double tmp;
	if (Math.abs(ky) <= 8e-172) {
		tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
	} else {
		tmp = (t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_1, 2.0)))) * Math.sin(th);
	}
	return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(math.fabs(ky))
	tmp = 0
	if math.fabs(ky) <= 8e-172:
		tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx)))
	else:
		tmp = (t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_1, 2.0)))) * math.sin(th)
	return math.copysign(1.0, ky) * tmp
function code(kx, ky, th)
	t_1 = sin(abs(ky))
	tmp = 0.0
	if (abs(ky) <= 8e-172)
		tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx))));
	else
		tmp = Float64(Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0)))) * sin(th));
	end
	return Float64(copysign(1.0, ky) * tmp)
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(abs(ky));
	tmp = 0.0;
	if (abs(ky) <= 8e-172)
		tmp = sin(th) * (abs(ky) / abs(sin(kx)));
	else
		tmp = (t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0)))) * sin(th);
	end
	tmp_2 = (sign(ky) * abs(1.0)) * tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[ky], $MachinePrecision], 3480865949723965/4351082437154956072465106588077822995084026820419845514849846380137705962380101572519219218556758308199541387151331336317719177934050977705242787666055883587123865770683541250307916824576], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|ky\right| \leq \frac{3480865949723965}{4351082437154956072465106588077822995084026820419845514849846380137705962380101572519219218556758308199541387151331336317719177934050977705242787666055883587123865770683541250307916824576}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}} \cdot \sin th\\


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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. div-flipN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      3. lower-unsound-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      4. lower-unsound-/.f6434.3%

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky \cdot \sin th}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky} \cdot \sin th}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\sin kx \cdot \sin kx}}{ky \cdot \sin th}} \]
      8. rem-sqrt-squareN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      9. lower-fabs.f6436.6%

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{ky \cdot \color{blue}{\sin th}}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\sin th \cdot \color{blue}{ky}}} \]
      12. lower-*.f6436.6%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{\sin th \cdot ky}}} \]
      3. div-flip-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\color{blue}{\left|\sin kx\right|}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\color{blue}{\sin kx}\right|} \]
      5. *-commutativeN/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\color{blue}{\sin kx}\right|} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      7. lift-fabs.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      8. rem-sqrt-square-revN/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\sin kx \cdot \sin kx}} \]
      9. unpow2N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      10. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      11. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{{\sin kx}^{2}}} \]
      14. unpow2N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\sin kx \cdot \sin kx}} \]
      15. rem-sqrt-square-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      16. lift-fabs.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      17. associate-/l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      18. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      19. lower-/.f6438.7%

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

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

    if 8.0000000000000003e-172 < ky

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 96.2% accurate, 1.0× speedup?

\[\begin{array}{l} t_1 := \sin \left(\left|ky\right|\right)\\ \mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l} \mathbf{if}\;\left|ky\right| \leq \frac{3480865949723965}{4351082437154956072465106588077822995084026820419845514849846380137705962380101572519219218556758308199541387151331336317719177934050977705242787666055883587123865770683541250307916824576}:\\ \;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\ \mathbf{elif}\;\left|ky\right| \leq \frac{7673845534663173}{73786976294838206464}:\\ \;\;\;\;\frac{t\_1}{\sqrt{{\sin kx}^{2} + {\left(\left|ky\right|\right)}^{2}}} \cdot \sin th\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin th \cdot t\_1}{\sqrt{\frac{1}{2} - \left(\cos \left(\left|ky\right| + \left|ky\right|\right) \cdot \frac{1}{2} + \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \frac{1}{2}\right)\right)}}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1 (sin (fabs ky))))
  (*
   (copysign 1 ky)
   (if (<=
        (fabs ky)
        3480865949723965/4351082437154956072465106588077822995084026820419845514849846380137705962380101572519219218556758308199541387151331336317719177934050977705242787666055883587123865770683541250307916824576)
     (* (sin th) (/ (fabs ky) (fabs (sin kx))))
     (if (<= (fabs ky) 7673845534663173/73786976294838206464)
       (*
        (/ t_1 (sqrt (+ (pow (sin kx) 2) (pow (fabs ky) 2))))
        (sin th))
       (/
        (* (sin th) t_1)
        (sqrt
         (-
          1/2
          (+
           (* (cos (+ (fabs ky) (fabs ky))) 1/2)
           (- (* (cos (+ kx kx)) 1/2) 1/2))))))))))
double code(double kx, double ky, double th) {
	double t_1 = sin(fabs(ky));
	double tmp;
	if (fabs(ky) <= 8e-172) {
		tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
	} else if (fabs(ky) <= 0.000104) {
		tmp = (t_1 / sqrt((pow(sin(kx), 2.0) + pow(fabs(ky), 2.0)))) * sin(th);
	} else {
		tmp = (sin(th) * t_1) / sqrt((0.5 - ((cos((fabs(ky) + fabs(ky))) * 0.5) + ((cos((kx + kx)) * 0.5) - 0.5))));
	}
	return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sin(Math.abs(ky));
	double tmp;
	if (Math.abs(ky) <= 8e-172) {
		tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
	} else if (Math.abs(ky) <= 0.000104) {
		tmp = (t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.abs(ky), 2.0)))) * Math.sin(th);
	} else {
		tmp = (Math.sin(th) * t_1) / Math.sqrt((0.5 - ((Math.cos((Math.abs(ky) + Math.abs(ky))) * 0.5) + ((Math.cos((kx + kx)) * 0.5) - 0.5))));
	}
	return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(math.fabs(ky))
	tmp = 0
	if math.fabs(ky) <= 8e-172:
		tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx)))
	elif math.fabs(ky) <= 0.000104:
		tmp = (t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.fabs(ky), 2.0)))) * math.sin(th)
	else:
		tmp = (math.sin(th) * t_1) / math.sqrt((0.5 - ((math.cos((math.fabs(ky) + math.fabs(ky))) * 0.5) + ((math.cos((kx + kx)) * 0.5) - 0.5))))
	return math.copysign(1.0, ky) * tmp
function code(kx, ky, th)
	t_1 = sin(abs(ky))
	tmp = 0.0
	if (abs(ky) <= 8e-172)
		tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx))));
	elseif (abs(ky) <= 0.000104)
		tmp = Float64(Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (abs(ky) ^ 2.0)))) * sin(th));
	else
		tmp = Float64(Float64(sin(th) * t_1) / sqrt(Float64(0.5 - Float64(Float64(cos(Float64(abs(ky) + abs(ky))) * 0.5) + Float64(Float64(cos(Float64(kx + kx)) * 0.5) - 0.5)))));
	end
	return Float64(copysign(1.0, ky) * tmp)
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(abs(ky));
	tmp = 0.0;
	if (abs(ky) <= 8e-172)
		tmp = sin(th) * (abs(ky) / abs(sin(kx)));
	elseif (abs(ky) <= 0.000104)
		tmp = (t_1 / sqrt(((sin(kx) ^ 2.0) + (abs(ky) ^ 2.0)))) * sin(th);
	else
		tmp = (sin(th) * t_1) / sqrt((0.5 - ((cos((abs(ky) + abs(ky))) * 0.5) + ((cos((kx + kx)) * 0.5) - 0.5))));
	end
	tmp_2 = (sign(ky) * abs(1.0)) * tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[ky], $MachinePrecision], 3480865949723965/4351082437154956072465106588077822995084026820419845514849846380137705962380101572519219218556758308199541387151331336317719177934050977705242787666055883587123865770683541250307916824576], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[ky], $MachinePrecision], 7673845534663173/73786976294838206464], N[(N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[N[Abs[ky], $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[th], $MachinePrecision] * t$95$1), $MachinePrecision] / N[Sqrt[N[(1/2 - N[(N[(N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1/2), $MachinePrecision] + N[(N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] * 1/2), $MachinePrecision] - 1/2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|ky\right| \leq \frac{3480865949723965}{4351082437154956072465106588077822995084026820419845514849846380137705962380101572519219218556758308199541387151331336317719177934050977705242787666055883587123865770683541250307916824576}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\

\mathbf{elif}\;\left|ky\right| \leq \frac{7673845534663173}{73786976294838206464}:\\
\;\;\;\;\frac{t\_1}{\sqrt{{\sin kx}^{2} + {\left(\left|ky\right|\right)}^{2}}} \cdot \sin th\\

\mathbf{else}:\\
\;\;\;\;\frac{\sin th \cdot t\_1}{\sqrt{\frac{1}{2} - \left(\cos \left(\left|ky\right| + \left|ky\right|\right) \cdot \frac{1}{2} + \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \frac{1}{2}\right)\right)}}\\


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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. div-flipN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      3. lower-unsound-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      4. lower-unsound-/.f6434.3%

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky \cdot \sin th}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky} \cdot \sin th}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\sin kx \cdot \sin kx}}{ky \cdot \sin th}} \]
      8. rem-sqrt-squareN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      9. lower-fabs.f6436.6%

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{ky \cdot \color{blue}{\sin th}}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\sin th \cdot \color{blue}{ky}}} \]
      12. lower-*.f6436.6%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{\sin th \cdot ky}}} \]
      3. div-flip-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\color{blue}{\left|\sin kx\right|}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\color{blue}{\sin kx}\right|} \]
      5. *-commutativeN/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\color{blue}{\sin kx}\right|} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      7. lift-fabs.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      8. rem-sqrt-square-revN/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\sin kx \cdot \sin kx}} \]
      9. unpow2N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      10. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      11. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{{\sin kx}^{2}}} \]
      14. unpow2N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\sin kx \cdot \sin kx}} \]
      15. rem-sqrt-square-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      16. lift-fabs.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      17. associate-/l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      18. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      19. lower-/.f6438.7%

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

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

    if 8.0000000000000003e-172 < ky < 1.0399999999999999e-4

    1. Initial program 93.7%

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

      \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{ky}^{2}}}} \cdot \sin th \]
    3. Step-by-step derivation
      1. lower-pow.f6446.7%

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

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

    if 1.0399999999999999e-4 < ky

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th} \]
      2. lift-/.f64N/A

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

        \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
      4. lower-/.f64N/A

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

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

        \[\leadsto \frac{\color{blue}{\sin th \cdot \sin ky}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \]
      7. lift-+.f64N/A

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

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \]
      9. add-flipN/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}}} \]
      10. lift-pow.f64N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      11. unpow2N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      12. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      14. sqr-sin-aN/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      15. associate--l-N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot ky\right) + \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)\right)}}} \]
      16. lower--.f64N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot ky\right) + \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)\right)}}} \]
      17. lower-+.f64N/A

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

      \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(ky + ky\right) \cdot \frac{1}{2} + \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \frac{1}{2}\right)\right)}}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 95.5% accurate, 0.5× speedup?

\[\begin{array}{l} t_1 := \sin \left(\left|ky\right|\right)\\ t_2 := {\sin kx}^{2}\\ \mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{t\_1}{\sqrt{t\_2 + {t\_1}^{2}}} \leq \frac{2206763817411543}{2251799813685248}:\\ \;\;\;\;\frac{t\_1}{\sqrt{t\_2 + \left(\frac{1}{2} - \cos \left(\left|ky\right| + \left|ky\right|\right) \cdot \frac{1}{2}\right)}} \cdot \sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1 (sin (fabs ky))) (t_2 (pow (sin kx) 2)))
  (*
   (copysign 1 ky)
   (if (<=
        (/ t_1 (sqrt (+ t_2 (pow t_1 2))))
        2206763817411543/2251799813685248)
     (*
      (/
       t_1
       (sqrt (+ t_2 (- 1/2 (* (cos (+ (fabs ky) (fabs ky))) 1/2)))))
      (sin th))
     (sin th)))))
double code(double kx, double ky, double th) {
	double t_1 = sin(fabs(ky));
	double t_2 = pow(sin(kx), 2.0);
	double tmp;
	if ((t_1 / sqrt((t_2 + pow(t_1, 2.0)))) <= 0.98) {
		tmp = (t_1 / sqrt((t_2 + (0.5 - (cos((fabs(ky) + fabs(ky))) * 0.5))))) * sin(th);
	} else {
		tmp = sin(th);
	}
	return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sin(Math.abs(ky));
	double t_2 = Math.pow(Math.sin(kx), 2.0);
	double tmp;
	if ((t_1 / Math.sqrt((t_2 + Math.pow(t_1, 2.0)))) <= 0.98) {
		tmp = (t_1 / Math.sqrt((t_2 + (0.5 - (Math.cos((Math.abs(ky) + Math.abs(ky))) * 0.5))))) * Math.sin(th);
	} else {
		tmp = Math.sin(th);
	}
	return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(math.fabs(ky))
	t_2 = math.pow(math.sin(kx), 2.0)
	tmp = 0
	if (t_1 / math.sqrt((t_2 + math.pow(t_1, 2.0)))) <= 0.98:
		tmp = (t_1 / math.sqrt((t_2 + (0.5 - (math.cos((math.fabs(ky) + math.fabs(ky))) * 0.5))))) * math.sin(th)
	else:
		tmp = math.sin(th)
	return math.copysign(1.0, ky) * tmp
function code(kx, ky, th)
	t_1 = sin(abs(ky))
	t_2 = sin(kx) ^ 2.0
	tmp = 0.0
	if (Float64(t_1 / sqrt(Float64(t_2 + (t_1 ^ 2.0)))) <= 0.98)
		tmp = Float64(Float64(t_1 / sqrt(Float64(t_2 + Float64(0.5 - Float64(cos(Float64(abs(ky) + abs(ky))) * 0.5))))) * sin(th));
	else
		tmp = sin(th);
	end
	return Float64(copysign(1.0, ky) * tmp)
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(abs(ky));
	t_2 = sin(kx) ^ 2.0;
	tmp = 0.0;
	if ((t_1 / sqrt((t_2 + (t_1 ^ 2.0)))) <= 0.98)
		tmp = (t_1 / sqrt((t_2 + (0.5 - (cos((abs(ky) + abs(ky))) * 0.5))))) * sin(th);
	else
		tmp = sin(th);
	end
	tmp_2 = (sign(ky) * abs(1.0)) * tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(t$95$1 / N[Sqrt[N[(t$95$2 + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2206763817411543/2251799813685248], N[(N[(t$95$1 / N[Sqrt[N[(t$95$2 + N[(1/2 - N[(N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]), $MachinePrecision]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := {\sin kx}^{2}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;\frac{t\_1}{\sqrt{t\_2 + {t\_1}^{2}}} \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;\frac{t\_1}{\sqrt{t\_2 + \left(\frac{1}{2} - \cos \left(\left|ky\right| + \left|ky\right|\right) \cdot \frac{1}{2}\right)}} \cdot \sin th\\

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


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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      2. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{\sin ky \cdot \sin ky}}} \cdot \sin th \]
      3. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{\sin ky} \cdot \sin ky}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \sin ky \cdot \color{blue}{\sin ky}}} \cdot \sin th \]
      5. sqr-sin-aN/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \cdot \sin th \]
      6. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \cdot \sin th \]
      7. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \color{blue}{\left(ky + ky\right)}\right)}} \cdot \sin th \]
      8. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \left(\frac{1}{2} - \color{blue}{\cos \left(ky + ky\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      9. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \left(\frac{1}{2} - \color{blue}{\cos \left(ky + ky\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      10. lower-cos.f64N/A

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

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

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Taylor expanded in ky around 0

      \[\leadsto \sin th \]
    8. Step-by-step derivation
      1. lower-sin.f6424.3%

        \[\leadsto \sin th \]
    9. Applied rewrites24.3%

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

Alternative 4: 94.4% accurate, 0.3× speedup?

\[\begin{array}{l} t_1 := \cos \left(kx + kx\right)\\ t_2 := \sin \left(\left|ky\right|\right)\\ t_3 := \sin th \cdot t\_2\\ t_4 := \frac{t\_2}{\sqrt{{\sin kx}^{2} + {t\_2}^{2}}}\\ t_5 := \cos \left(\left|ky\right| + \left|ky\right|\right)\\ \mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l} \mathbf{if}\;t\_4 \leq \frac{-3602879701896397}{36028797018963968}:\\ \;\;\;\;\frac{t\_3}{\sqrt{\frac{1}{2} - \left(t\_5 \cdot \frac{1}{2} + \left(t\_1 \cdot \frac{1}{2} - \frac{1}{2}\right)\right)}}\\ \mathbf{elif}\;t\_4 \leq \frac{5316911983139663}{5316911983139663491615228241121378304}:\\ \;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\ \mathbf{elif}\;t\_4 \leq \frac{2206763817411543}{2251799813685248}:\\ \;\;\;\;\frac{t\_3}{\sqrt{\frac{1}{2} - \left(t\_1 - \left(1 - t\_5\right)\right) \cdot \frac{1}{2}}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1 (cos (+ kx kx)))
       (t_2 (sin (fabs ky)))
       (t_3 (* (sin th) t_2))
       (t_4 (/ t_2 (sqrt (+ (pow (sin kx) 2) (pow t_2 2)))))
       (t_5 (cos (+ (fabs ky) (fabs ky)))))
  (*
   (copysign 1 ky)
   (if (<= t_4 -3602879701896397/36028797018963968)
     (/ t_3 (sqrt (- 1/2 (+ (* t_5 1/2) (- (* t_1 1/2) 1/2)))))
     (if (<=
          t_4
          5316911983139663/5316911983139663491615228241121378304)
       (* (sin th) (/ (fabs ky) (fabs (sin kx))))
       (if (<= t_4 2206763817411543/2251799813685248)
         (/ t_3 (sqrt (- 1/2 (* (- t_1 (- 1 t_5)) 1/2))))
         (sin th)))))))
double code(double kx, double ky, double th) {
	double t_1 = cos((kx + kx));
	double t_2 = sin(fabs(ky));
	double t_3 = sin(th) * t_2;
	double t_4 = t_2 / sqrt((pow(sin(kx), 2.0) + pow(t_2, 2.0)));
	double t_5 = cos((fabs(ky) + fabs(ky)));
	double tmp;
	if (t_4 <= -0.1) {
		tmp = t_3 / sqrt((0.5 - ((t_5 * 0.5) + ((t_1 * 0.5) - 0.5))));
	} else if (t_4 <= 1e-21) {
		tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
	} else if (t_4 <= 0.98) {
		tmp = t_3 / sqrt((0.5 - ((t_1 - (1.0 - t_5)) * 0.5)));
	} else {
		tmp = sin(th);
	}
	return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.cos((kx + kx));
	double t_2 = Math.sin(Math.abs(ky));
	double t_3 = Math.sin(th) * t_2;
	double t_4 = t_2 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_2, 2.0)));
	double t_5 = Math.cos((Math.abs(ky) + Math.abs(ky)));
	double tmp;
	if (t_4 <= -0.1) {
		tmp = t_3 / Math.sqrt((0.5 - ((t_5 * 0.5) + ((t_1 * 0.5) - 0.5))));
	} else if (t_4 <= 1e-21) {
		tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
	} else if (t_4 <= 0.98) {
		tmp = t_3 / Math.sqrt((0.5 - ((t_1 - (1.0 - t_5)) * 0.5)));
	} else {
		tmp = Math.sin(th);
	}
	return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th):
	t_1 = math.cos((kx + kx))
	t_2 = math.sin(math.fabs(ky))
	t_3 = math.sin(th) * t_2
	t_4 = t_2 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_2, 2.0)))
	t_5 = math.cos((math.fabs(ky) + math.fabs(ky)))
	tmp = 0
	if t_4 <= -0.1:
		tmp = t_3 / math.sqrt((0.5 - ((t_5 * 0.5) + ((t_1 * 0.5) - 0.5))))
	elif t_4 <= 1e-21:
		tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx)))
	elif t_4 <= 0.98:
		tmp = t_3 / math.sqrt((0.5 - ((t_1 - (1.0 - t_5)) * 0.5)))
	else:
		tmp = math.sin(th)
	return math.copysign(1.0, ky) * tmp
function code(kx, ky, th)
	t_1 = cos(Float64(kx + kx))
	t_2 = sin(abs(ky))
	t_3 = Float64(sin(th) * t_2)
	t_4 = Float64(t_2 / sqrt(Float64((sin(kx) ^ 2.0) + (t_2 ^ 2.0))))
	t_5 = cos(Float64(abs(ky) + abs(ky)))
	tmp = 0.0
	if (t_4 <= -0.1)
		tmp = Float64(t_3 / sqrt(Float64(0.5 - Float64(Float64(t_5 * 0.5) + Float64(Float64(t_1 * 0.5) - 0.5)))));
	elseif (t_4 <= 1e-21)
		tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx))));
	elseif (t_4 <= 0.98)
		tmp = Float64(t_3 / sqrt(Float64(0.5 - Float64(Float64(t_1 - Float64(1.0 - t_5)) * 0.5))));
	else
		tmp = sin(th);
	end
	return Float64(copysign(1.0, ky) * tmp)
end
function tmp_2 = code(kx, ky, th)
	t_1 = cos((kx + kx));
	t_2 = sin(abs(ky));
	t_3 = sin(th) * t_2;
	t_4 = t_2 / sqrt(((sin(kx) ^ 2.0) + (t_2 ^ 2.0)));
	t_5 = cos((abs(ky) + abs(ky)));
	tmp = 0.0;
	if (t_4 <= -0.1)
		tmp = t_3 / sqrt((0.5 - ((t_5 * 0.5) + ((t_1 * 0.5) - 0.5))));
	elseif (t_4 <= 1e-21)
		tmp = sin(th) * (abs(ky) / abs(sin(kx)));
	elseif (t_4 <= 0.98)
		tmp = t_3 / sqrt((0.5 - ((t_1 - (1.0 - t_5)) * 0.5)));
	else
		tmp = sin(th);
	end
	tmp_2 = (sign(ky) * abs(1.0)) * tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[th], $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$2, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$4, -3602879701896397/36028797018963968], N[(t$95$3 / N[Sqrt[N[(1/2 - N[(N[(t$95$5 * 1/2), $MachinePrecision] + N[(N[(t$95$1 * 1/2), $MachinePrecision] - 1/2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 5316911983139663/5316911983139663491615228241121378304], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 2206763817411543/2251799813685248], N[(t$95$3 / N[Sqrt[N[(1/2 - N[(N[(t$95$1 - N[(1 - t$95$5), $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]), $MachinePrecision]]]]]]
\begin{array}{l}
t_1 := \cos \left(kx + kx\right)\\
t_2 := \sin \left(\left|ky\right|\right)\\
t_3 := \sin th \cdot t\_2\\
t_4 := \frac{t\_2}{\sqrt{{\sin kx}^{2} + {t\_2}^{2}}}\\
t_5 := \cos \left(\left|ky\right| + \left|ky\right|\right)\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_4 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;\frac{t\_3}{\sqrt{\frac{1}{2} - \left(t\_5 \cdot \frac{1}{2} + \left(t\_1 \cdot \frac{1}{2} - \frac{1}{2}\right)\right)}}\\

\mathbf{elif}\;t\_4 \leq \frac{5316911983139663}{5316911983139663491615228241121378304}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\

\mathbf{elif}\;t\_4 \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;\frac{t\_3}{\sqrt{\frac{1}{2} - \left(t\_1 - \left(1 - t\_5\right)\right) \cdot \frac{1}{2}}}\\

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


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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th} \]
      2. lift-/.f64N/A

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

        \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
      4. lower-/.f64N/A

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

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

        \[\leadsto \frac{\color{blue}{\sin th \cdot \sin ky}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \]
      7. lift-+.f64N/A

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

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \]
      9. add-flipN/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}}} \]
      10. lift-pow.f64N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      11. unpow2N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      12. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      14. sqr-sin-aN/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      15. associate--l-N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot ky\right) + \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)\right)}}} \]
      16. lower--.f64N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot ky\right) + \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)\right)}}} \]
      17. lower-+.f64N/A

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

      \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(ky + ky\right) \cdot \frac{1}{2} + \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \frac{1}{2}\right)\right)}}} \]

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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. div-flipN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      3. lower-unsound-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      4. lower-unsound-/.f6434.3%

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky \cdot \sin th}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky} \cdot \sin th}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\sin kx \cdot \sin kx}}{ky \cdot \sin th}} \]
      8. rem-sqrt-squareN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      9. lower-fabs.f6436.6%

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{ky \cdot \color{blue}{\sin th}}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\sin th \cdot \color{blue}{ky}}} \]
      12. lower-*.f6436.6%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{\sin th \cdot ky}}} \]
      3. div-flip-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\color{blue}{\left|\sin kx\right|}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\color{blue}{\sin kx}\right|} \]
      5. *-commutativeN/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\color{blue}{\sin kx}\right|} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      7. lift-fabs.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      8. rem-sqrt-square-revN/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\sin kx \cdot \sin kx}} \]
      9. unpow2N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      10. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      11. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{{\sin kx}^{2}}} \]
      14. unpow2N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\sin kx \cdot \sin kx}} \]
      15. rem-sqrt-square-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      16. lift-fabs.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      17. associate-/l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      18. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      19. lower-/.f6438.7%

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

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th} \]
      2. lift-/.f64N/A

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

        \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
      4. lower-/.f64N/A

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

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

        \[\leadsto \frac{\color{blue}{\sin th \cdot \sin ky}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \]
      7. lift-+.f64N/A

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

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \]
      9. add-flipN/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}}} \]
      10. lift-pow.f64N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      11. unpow2N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      12. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      14. sqr-sin-aN/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      15. associate--l-N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot ky\right) + \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)\right)}}} \]
      16. lower--.f64N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot ky\right) + \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)\right)}}} \]
      17. lower-+.f64N/A

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

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

      \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\cos \left(kx + kx\right) - \left(1 - \cos \left(ky + ky\right)\right)\right) \cdot \frac{1}{2}}}} \]

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Taylor expanded in ky around 0

      \[\leadsto \sin th \]
    8. Step-by-step derivation
      1. lower-sin.f6424.3%

        \[\leadsto \sin th \]
    9. Applied rewrites24.3%

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

Alternative 5: 94.4% accurate, 0.3× speedup?

\[\begin{array}{l} t_1 := \sin \left(\left|ky\right|\right)\\ t_2 := \frac{\sin th \cdot t\_1}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) - \left(1 - \cos \left(\left|ky\right| + \left|ky\right|\right)\right)\right) \cdot \frac{1}{2}}}\\ t_3 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\ \mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l} \mathbf{if}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_3 \leq \frac{5316911983139663}{5316911983139663491615228241121378304}:\\ \;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\ \mathbf{elif}\;t\_3 \leq \frac{2206763817411543}{2251799813685248}:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1 (sin (fabs ky)))
       (t_2
        (/
         (* (sin th) t_1)
         (sqrt
          (-
           1/2
           (*
            (- (cos (+ kx kx)) (- 1 (cos (+ (fabs ky) (fabs ky)))))
            1/2)))))
       (t_3 (/ t_1 (sqrt (+ (pow (sin kx) 2) (pow t_1 2))))))
  (*
   (copysign 1 ky)
   (if (<= t_3 -3602879701896397/36028797018963968)
     t_2
     (if (<=
          t_3
          5316911983139663/5316911983139663491615228241121378304)
       (* (sin th) (/ (fabs ky) (fabs (sin kx))))
       (if (<= t_3 2206763817411543/2251799813685248)
         t_2
         (sin th)))))))
double code(double kx, double ky, double th) {
	double t_1 = sin(fabs(ky));
	double t_2 = (sin(th) * t_1) / sqrt((0.5 - ((cos((kx + kx)) - (1.0 - cos((fabs(ky) + fabs(ky))))) * 0.5)));
	double t_3 = t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)));
	double tmp;
	if (t_3 <= -0.1) {
		tmp = t_2;
	} else if (t_3 <= 1e-21) {
		tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
	} else if (t_3 <= 0.98) {
		tmp = t_2;
	} else {
		tmp = sin(th);
	}
	return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sin(Math.abs(ky));
	double t_2 = (Math.sin(th) * t_1) / Math.sqrt((0.5 - ((Math.cos((kx + kx)) - (1.0 - Math.cos((Math.abs(ky) + Math.abs(ky))))) * 0.5)));
	double t_3 = t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_1, 2.0)));
	double tmp;
	if (t_3 <= -0.1) {
		tmp = t_2;
	} else if (t_3 <= 1e-21) {
		tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
	} else if (t_3 <= 0.98) {
		tmp = t_2;
	} else {
		tmp = Math.sin(th);
	}
	return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(math.fabs(ky))
	t_2 = (math.sin(th) * t_1) / math.sqrt((0.5 - ((math.cos((kx + kx)) - (1.0 - math.cos((math.fabs(ky) + math.fabs(ky))))) * 0.5)))
	t_3 = t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_1, 2.0)))
	tmp = 0
	if t_3 <= -0.1:
		tmp = t_2
	elif t_3 <= 1e-21:
		tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx)))
	elif t_3 <= 0.98:
		tmp = t_2
	else:
		tmp = math.sin(th)
	return math.copysign(1.0, ky) * tmp
function code(kx, ky, th)
	t_1 = sin(abs(ky))
	t_2 = Float64(Float64(sin(th) * t_1) / sqrt(Float64(0.5 - Float64(Float64(cos(Float64(kx + kx)) - Float64(1.0 - cos(Float64(abs(ky) + abs(ky))))) * 0.5))))
	t_3 = Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0))))
	tmp = 0.0
	if (t_3 <= -0.1)
		tmp = t_2;
	elseif (t_3 <= 1e-21)
		tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx))));
	elseif (t_3 <= 0.98)
		tmp = t_2;
	else
		tmp = sin(th);
	end
	return Float64(copysign(1.0, ky) * tmp)
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(abs(ky));
	t_2 = (sin(th) * t_1) / sqrt((0.5 - ((cos((kx + kx)) - (1.0 - cos((abs(ky) + abs(ky))))) * 0.5)));
	t_3 = t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0)));
	tmp = 0.0;
	if (t_3 <= -0.1)
		tmp = t_2;
	elseif (t_3 <= 1e-21)
		tmp = sin(th) * (abs(ky) / abs(sin(kx)));
	elseif (t_3 <= 0.98)
		tmp = t_2;
	else
		tmp = sin(th);
	end
	tmp_2 = (sign(ky) * abs(1.0)) * tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Sin[th], $MachinePrecision] * t$95$1), $MachinePrecision] / N[Sqrt[N[(1/2 - N[(N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] - N[(1 - N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, -3602879701896397/36028797018963968], t$95$2, If[LessEqual[t$95$3, 5316911983139663/5316911983139663491615228241121378304], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2206763817411543/2251799813685248], t$95$2, N[Sin[th], $MachinePrecision]]]]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := \frac{\sin th \cdot t\_1}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) - \left(1 - \cos \left(\left|ky\right| + \left|ky\right|\right)\right)\right) \cdot \frac{1}{2}}}\\
t_3 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_3 \leq \frac{5316911983139663}{5316911983139663491615228241121378304}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\

\mathbf{elif}\;t\_3 \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;t\_2\\

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


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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th} \]
      2. lift-/.f64N/A

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

        \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}} \]
      4. lower-/.f64N/A

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

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

        \[\leadsto \frac{\color{blue}{\sin th \cdot \sin ky}}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \]
      7. lift-+.f64N/A

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

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \]
      9. add-flipN/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}}} \]
      10. lift-pow.f64N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{{\sin ky}^{2}} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      11. unpow2N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      12. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\sin ky} \cdot \sin ky - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\sin ky \cdot \color{blue}{\sin ky} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      14. sqr-sin-aN/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)} - \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)}} \]
      15. associate--l-N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot ky\right) + \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)\right)}}} \]
      16. lower--.f64N/A

        \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot ky\right) + \left(\mathsf{neg}\left({\sin kx}^{2}\right)\right)\right)}}} \]
      17. lower-+.f64N/A

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

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

      \[\leadsto \frac{\sin th \cdot \sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\cos \left(kx + kx\right) - \left(1 - \cos \left(ky + ky\right)\right)\right) \cdot \frac{1}{2}}}} \]

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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. div-flipN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      3. lower-unsound-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      4. lower-unsound-/.f6434.3%

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky \cdot \sin th}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky} \cdot \sin th}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\sin kx \cdot \sin kx}}{ky \cdot \sin th}} \]
      8. rem-sqrt-squareN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      9. lower-fabs.f6436.6%

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{ky \cdot \color{blue}{\sin th}}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\sin th \cdot \color{blue}{ky}}} \]
      12. lower-*.f6436.6%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{\sin th \cdot ky}}} \]
      3. div-flip-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\color{blue}{\left|\sin kx\right|}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\color{blue}{\sin kx}\right|} \]
      5. *-commutativeN/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\color{blue}{\sin kx}\right|} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      7. lift-fabs.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      8. rem-sqrt-square-revN/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\sin kx \cdot \sin kx}} \]
      9. unpow2N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      10. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      11. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{{\sin kx}^{2}}} \]
      14. unpow2N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\sin kx \cdot \sin kx}} \]
      15. rem-sqrt-square-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      16. lift-fabs.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      17. associate-/l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      18. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      19. lower-/.f6438.7%

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

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Taylor expanded in ky around 0

      \[\leadsto \sin th \]
    8. Step-by-step derivation
      1. lower-sin.f6424.3%

        \[\leadsto \sin th \]
    9. Applied rewrites24.3%

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

Alternative 6: 94.3% accurate, 0.3× speedup?

\[\begin{array}{l} t_1 := \sin \left(\left|ky\right|\right)\\ t_2 := \frac{\sin th \cdot t\_1}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}}\\ t_3 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\ \mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l} \mathbf{if}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_3 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\ \;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\ \mathbf{elif}\;t\_3 \leq \frac{2206763817411543}{2251799813685248}:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1 (sin (fabs ky)))
       (t_2
        (/
         (* (sin th) t_1)
         (sqrt
          (-
           1
           (*
            (+ (cos (+ kx kx)) (cos (+ (fabs ky) (fabs ky))))
            1/2)))))
       (t_3 (/ t_1 (sqrt (+ (pow (sin kx) 2) (pow t_1 2))))))
  (*
   (copysign 1 ky)
   (if (<= t_3 -3602879701896397/36028797018963968)
     t_2
     (if (<=
          t_3
          2857840190937569/664613997892457936451903530140172288)
       (* (sin th) (/ (fabs ky) (fabs (sin kx))))
       (if (<= t_3 2206763817411543/2251799813685248)
         t_2
         (sin th)))))))
double code(double kx, double ky, double th) {
	double t_1 = sin(fabs(ky));
	double t_2 = (sin(th) * t_1) / sqrt((1.0 - ((cos((kx + kx)) + cos((fabs(ky) + fabs(ky)))) * 0.5)));
	double t_3 = t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)));
	double tmp;
	if (t_3 <= -0.1) {
		tmp = t_2;
	} else if (t_3 <= 4.3e-21) {
		tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
	} else if (t_3 <= 0.98) {
		tmp = t_2;
	} else {
		tmp = sin(th);
	}
	return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sin(Math.abs(ky));
	double t_2 = (Math.sin(th) * t_1) / Math.sqrt((1.0 - ((Math.cos((kx + kx)) + Math.cos((Math.abs(ky) + Math.abs(ky)))) * 0.5)));
	double t_3 = t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_1, 2.0)));
	double tmp;
	if (t_3 <= -0.1) {
		tmp = t_2;
	} else if (t_3 <= 4.3e-21) {
		tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
	} else if (t_3 <= 0.98) {
		tmp = t_2;
	} else {
		tmp = Math.sin(th);
	}
	return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(math.fabs(ky))
	t_2 = (math.sin(th) * t_1) / math.sqrt((1.0 - ((math.cos((kx + kx)) + math.cos((math.fabs(ky) + math.fabs(ky)))) * 0.5)))
	t_3 = t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_1, 2.0)))
	tmp = 0
	if t_3 <= -0.1:
		tmp = t_2
	elif t_3 <= 4.3e-21:
		tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx)))
	elif t_3 <= 0.98:
		tmp = t_2
	else:
		tmp = math.sin(th)
	return math.copysign(1.0, ky) * tmp
function code(kx, ky, th)
	t_1 = sin(abs(ky))
	t_2 = Float64(Float64(sin(th) * t_1) / sqrt(Float64(1.0 - Float64(Float64(cos(Float64(kx + kx)) + cos(Float64(abs(ky) + abs(ky)))) * 0.5))))
	t_3 = Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0))))
	tmp = 0.0
	if (t_3 <= -0.1)
		tmp = t_2;
	elseif (t_3 <= 4.3e-21)
		tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx))));
	elseif (t_3 <= 0.98)
		tmp = t_2;
	else
		tmp = sin(th);
	end
	return Float64(copysign(1.0, ky) * tmp)
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(abs(ky));
	t_2 = (sin(th) * t_1) / sqrt((1.0 - ((cos((kx + kx)) + cos((abs(ky) + abs(ky)))) * 0.5)));
	t_3 = t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0)));
	tmp = 0.0;
	if (t_3 <= -0.1)
		tmp = t_2;
	elseif (t_3 <= 4.3e-21)
		tmp = sin(th) * (abs(ky) / abs(sin(kx)));
	elseif (t_3 <= 0.98)
		tmp = t_2;
	else
		tmp = sin(th);
	end
	tmp_2 = (sign(ky) * abs(1.0)) * tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Sin[th], $MachinePrecision] * t$95$1), $MachinePrecision] / N[Sqrt[N[(1 - N[(N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, -3602879701896397/36028797018963968], t$95$2, If[LessEqual[t$95$3, 2857840190937569/664613997892457936451903530140172288], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2206763817411543/2251799813685248], t$95$2, N[Sin[th], $MachinePrecision]]]]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := \frac{\sin th \cdot t\_1}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}}\\
t_3 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_3 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\

\mathbf{elif}\;t\_3 \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;t\_2\\

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


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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      2. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{\sin ky \cdot \sin ky}}} \cdot \sin th \]
      3. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{\sin ky} \cdot \sin ky}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \sin ky \cdot \color{blue}{\sin ky}}} \cdot \sin th \]
      5. sqr-sin-aN/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \cdot \sin th \]
      6. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \cdot \sin th \]
      7. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \color{blue}{\left(ky + ky\right)}\right)}} \cdot \sin th \]
      8. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \left(\frac{1}{2} - \color{blue}{\cos \left(ky + ky\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      9. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \left(\frac{1}{2} - \color{blue}{\cos \left(ky + ky\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      10. lower-cos.f64N/A

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

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

      \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{\left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right)}}} \cdot \sin th \]
    4. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + \left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right)}}} \cdot \sin th \]
      2. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) + {\sin kx}^{2}}}} \cdot \sin th \]
      3. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      5. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) - \left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx}}} \cdot \sin th \]
      6. flip3--N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{{\left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right)}^{3} - {\left(\left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx\right)}^{3}}{\left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) \cdot \left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) + \left(\left(\left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx\right) \cdot \left(\left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx\right) + \left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) \cdot \left(\left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx\right)\right)}}}} \cdot \sin th \]
      7. lower-unsound-/.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{{\left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right)}^{3} - {\left(\left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx\right)}^{3}}{\left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) \cdot \left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) + \left(\left(\left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx\right) \cdot \left(\left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx\right) + \left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) \cdot \left(\left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx\right)\right)}}}} \cdot \sin th \]
    5. Applied rewrites77.8%

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

      \[\leadsto \color{blue}{\frac{\sin th \cdot \sin ky}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}}} \]

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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. div-flipN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      3. lower-unsound-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      4. lower-unsound-/.f6434.3%

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky \cdot \sin th}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky} \cdot \sin th}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\sin kx \cdot \sin kx}}{ky \cdot \sin th}} \]
      8. rem-sqrt-squareN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      9. lower-fabs.f6436.6%

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{ky \cdot \color{blue}{\sin th}}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\sin th \cdot \color{blue}{ky}}} \]
      12. lower-*.f6436.6%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{\sin th \cdot ky}}} \]
      3. div-flip-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\color{blue}{\left|\sin kx\right|}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\color{blue}{\sin kx}\right|} \]
      5. *-commutativeN/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\color{blue}{\sin kx}\right|} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      7. lift-fabs.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      8. rem-sqrt-square-revN/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\sin kx \cdot \sin kx}} \]
      9. unpow2N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      10. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      11. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{{\sin kx}^{2}}} \]
      14. unpow2N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\sin kx \cdot \sin kx}} \]
      15. rem-sqrt-square-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      16. lift-fabs.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      17. associate-/l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      18. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      19. lower-/.f6438.7%

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

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Taylor expanded in ky around 0

      \[\leadsto \sin th \]
    8. Step-by-step derivation
      1. lower-sin.f6424.3%

        \[\leadsto \sin th \]
    9. Applied rewrites24.3%

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

Alternative 7: 94.3% accurate, 0.3× speedup?

\[\begin{array}{l} t_1 := \sin \left(\left|ky\right|\right)\\ t_2 := t\_1 \cdot \frac{\sin th}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}}\\ t_3 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\ \mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l} \mathbf{if}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_3 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\ \;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\ \mathbf{elif}\;t\_3 \leq \frac{2206763817411543}{2251799813685248}:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1 (sin (fabs ky)))
       (t_2
        (*
         t_1
         (/
          (sin th)
          (sqrt
           (-
            1
            (*
             (+ (cos (+ kx kx)) (cos (+ (fabs ky) (fabs ky))))
             1/2))))))
       (t_3 (/ t_1 (sqrt (+ (pow (sin kx) 2) (pow t_1 2))))))
  (*
   (copysign 1 ky)
   (if (<= t_3 -3602879701896397/36028797018963968)
     t_2
     (if (<=
          t_3
          2857840190937569/664613997892457936451903530140172288)
       (* (sin th) (/ (fabs ky) (fabs (sin kx))))
       (if (<= t_3 2206763817411543/2251799813685248)
         t_2
         (sin th)))))))
double code(double kx, double ky, double th) {
	double t_1 = sin(fabs(ky));
	double t_2 = t_1 * (sin(th) / sqrt((1.0 - ((cos((kx + kx)) + cos((fabs(ky) + fabs(ky)))) * 0.5))));
	double t_3 = t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)));
	double tmp;
	if (t_3 <= -0.1) {
		tmp = t_2;
	} else if (t_3 <= 4.3e-21) {
		tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
	} else if (t_3 <= 0.98) {
		tmp = t_2;
	} else {
		tmp = sin(th);
	}
	return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sin(Math.abs(ky));
	double t_2 = t_1 * (Math.sin(th) / Math.sqrt((1.0 - ((Math.cos((kx + kx)) + Math.cos((Math.abs(ky) + Math.abs(ky)))) * 0.5))));
	double t_3 = t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_1, 2.0)));
	double tmp;
	if (t_3 <= -0.1) {
		tmp = t_2;
	} else if (t_3 <= 4.3e-21) {
		tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
	} else if (t_3 <= 0.98) {
		tmp = t_2;
	} else {
		tmp = Math.sin(th);
	}
	return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(math.fabs(ky))
	t_2 = t_1 * (math.sin(th) / math.sqrt((1.0 - ((math.cos((kx + kx)) + math.cos((math.fabs(ky) + math.fabs(ky)))) * 0.5))))
	t_3 = t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_1, 2.0)))
	tmp = 0
	if t_3 <= -0.1:
		tmp = t_2
	elif t_3 <= 4.3e-21:
		tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx)))
	elif t_3 <= 0.98:
		tmp = t_2
	else:
		tmp = math.sin(th)
	return math.copysign(1.0, ky) * tmp
function code(kx, ky, th)
	t_1 = sin(abs(ky))
	t_2 = Float64(t_1 * Float64(sin(th) / sqrt(Float64(1.0 - Float64(Float64(cos(Float64(kx + kx)) + cos(Float64(abs(ky) + abs(ky)))) * 0.5)))))
	t_3 = Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0))))
	tmp = 0.0
	if (t_3 <= -0.1)
		tmp = t_2;
	elseif (t_3 <= 4.3e-21)
		tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx))));
	elseif (t_3 <= 0.98)
		tmp = t_2;
	else
		tmp = sin(th);
	end
	return Float64(copysign(1.0, ky) * tmp)
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(abs(ky));
	t_2 = t_1 * (sin(th) / sqrt((1.0 - ((cos((kx + kx)) + cos((abs(ky) + abs(ky)))) * 0.5))));
	t_3 = t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0)));
	tmp = 0.0;
	if (t_3 <= -0.1)
		tmp = t_2;
	elseif (t_3 <= 4.3e-21)
		tmp = sin(th) * (abs(ky) / abs(sin(kx)));
	elseif (t_3 <= 0.98)
		tmp = t_2;
	else
		tmp = sin(th);
	end
	tmp_2 = (sign(ky) * abs(1.0)) * tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[(1 - N[(N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, -3602879701896397/36028797018963968], t$95$2, If[LessEqual[t$95$3, 2857840190937569/664613997892457936451903530140172288], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2206763817411543/2251799813685248], t$95$2, N[Sin[th], $MachinePrecision]]]]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := t\_1 \cdot \frac{\sin th}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}}\\
t_3 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_3 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\

\mathbf{elif}\;t\_3 \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;t\_2\\

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


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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{{\sin ky}^{2}}}} \cdot \sin th \]
      2. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{\sin ky \cdot \sin ky}}} \cdot \sin th \]
      3. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{\sin ky} \cdot \sin ky}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \sin ky \cdot \color{blue}{\sin ky}}} \cdot \sin th \]
      5. sqr-sin-aN/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \cdot \sin th \]
      6. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \cdot \sin th \]
      7. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \color{blue}{\left(ky + ky\right)}\right)}} \cdot \sin th \]
      8. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \left(\frac{1}{2} - \color{blue}{\cos \left(ky + ky\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      9. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \left(\frac{1}{2} - \color{blue}{\cos \left(ky + ky\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      10. lower-cos.f64N/A

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

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

      \[\leadsto \frac{\sin ky}{\sqrt{{\sin kx}^{2} + \color{blue}{\left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right)}}} \cdot \sin th \]
    4. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + \left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right)}}} \cdot \sin th \]
      2. +-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) + {\sin kx}^{2}}}} \cdot \sin th \]
      3. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]
      5. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) - \left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx}}} \cdot \sin th \]
      6. flip3--N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{{\left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right)}^{3} - {\left(\left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx\right)}^{3}}{\left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) \cdot \left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) + \left(\left(\left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx\right) \cdot \left(\left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx\right) + \left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) \cdot \left(\left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx\right)\right)}}}} \cdot \sin th \]
      7. lower-unsound-/.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{{\left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right)}^{3} - {\left(\left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx\right)}^{3}}{\left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) \cdot \left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) + \left(\left(\left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx\right) \cdot \left(\left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx\right) + \left(\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}\right) \cdot \left(\left(\mathsf{neg}\left(\sin kx\right)\right) \cdot \sin kx\right)\right)}}}} \cdot \sin th \]
    5. Applied rewrites77.8%

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

      \[\leadsto \color{blue}{\sin ky \cdot \frac{\sin th}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}}} \]

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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. div-flipN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      3. lower-unsound-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      4. lower-unsound-/.f6434.3%

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky \cdot \sin th}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky} \cdot \sin th}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\sin kx \cdot \sin kx}}{ky \cdot \sin th}} \]
      8. rem-sqrt-squareN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      9. lower-fabs.f6436.6%

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{ky \cdot \color{blue}{\sin th}}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\sin th \cdot \color{blue}{ky}}} \]
      12. lower-*.f6436.6%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{\sin th \cdot ky}}} \]
      3. div-flip-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\color{blue}{\left|\sin kx\right|}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\color{blue}{\sin kx}\right|} \]
      5. *-commutativeN/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\color{blue}{\sin kx}\right|} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      7. lift-fabs.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      8. rem-sqrt-square-revN/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\sin kx \cdot \sin kx}} \]
      9. unpow2N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      10. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      11. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{{\sin kx}^{2}}} \]
      14. unpow2N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\sin kx \cdot \sin kx}} \]
      15. rem-sqrt-square-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      16. lift-fabs.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      17. associate-/l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      18. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      19. lower-/.f6438.7%

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

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Taylor expanded in ky around 0

      \[\leadsto \sin th \]
    8. Step-by-step derivation
      1. lower-sin.f6424.3%

        \[\leadsto \sin th \]
    9. Applied rewrites24.3%

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

Alternative 8: 82.5% accurate, 0.2× speedup?

\[\begin{array}{l} t_1 := \sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}\\ t_2 := \sin \left(\left|ky\right|\right)\\ t_3 := \frac{t\_2}{\sqrt{{\sin kx}^{2} + {t\_2}^{2}}}\\ t_4 := -t\_2\\ \mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l} \mathbf{if}\;t\_3 \leq -1:\\ \;\;\;\;\frac{t\_2}{\left|t\_2\right|} \cdot \sin th\\ \mathbf{elif}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\ \;\;\;\;t\_4 \cdot \frac{1}{\frac{t\_1}{-th}}\\ \mathbf{elif}\;t\_3 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\ \;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\ \mathbf{elif}\;t\_3 \leq \frac{2206763817411543}{2251799813685248}:\\ \;\;\;\;t\_4 \cdot \left(th \cdot \frac{-1}{t\_1}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1
        (sqrt
         (-
          1
          (* (+ (cos (+ kx kx)) (cos (+ (fabs ky) (fabs ky)))) 1/2))))
       (t_2 (sin (fabs ky)))
       (t_3 (/ t_2 (sqrt (+ (pow (sin kx) 2) (pow t_2 2)))))
       (t_4 (- t_2)))
  (*
   (copysign 1 ky)
   (if (<= t_3 -1)
     (* (/ t_2 (fabs t_2)) (sin th))
     (if (<= t_3 -3602879701896397/36028797018963968)
       (* t_4 (/ 1 (/ t_1 (- th))))
       (if (<=
            t_3
            2857840190937569/664613997892457936451903530140172288)
         (* (sin th) (/ (fabs ky) (fabs (sin kx))))
         (if (<= t_3 2206763817411543/2251799813685248)
           (* t_4 (* th (/ -1 t_1)))
           (sin th))))))))
double code(double kx, double ky, double th) {
	double t_1 = sqrt((1.0 - ((cos((kx + kx)) + cos((fabs(ky) + fabs(ky)))) * 0.5)));
	double t_2 = sin(fabs(ky));
	double t_3 = t_2 / sqrt((pow(sin(kx), 2.0) + pow(t_2, 2.0)));
	double t_4 = -t_2;
	double tmp;
	if (t_3 <= -1.0) {
		tmp = (t_2 / fabs(t_2)) * sin(th);
	} else if (t_3 <= -0.1) {
		tmp = t_4 * (1.0 / (t_1 / -th));
	} else if (t_3 <= 4.3e-21) {
		tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
	} else if (t_3 <= 0.98) {
		tmp = t_4 * (th * (-1.0 / t_1));
	} else {
		tmp = sin(th);
	}
	return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sqrt((1.0 - ((Math.cos((kx + kx)) + Math.cos((Math.abs(ky) + Math.abs(ky)))) * 0.5)));
	double t_2 = Math.sin(Math.abs(ky));
	double t_3 = t_2 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_2, 2.0)));
	double t_4 = -t_2;
	double tmp;
	if (t_3 <= -1.0) {
		tmp = (t_2 / Math.abs(t_2)) * Math.sin(th);
	} else if (t_3 <= -0.1) {
		tmp = t_4 * (1.0 / (t_1 / -th));
	} else if (t_3 <= 4.3e-21) {
		tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
	} else if (t_3 <= 0.98) {
		tmp = t_4 * (th * (-1.0 / t_1));
	} else {
		tmp = Math.sin(th);
	}
	return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th):
	t_1 = math.sqrt((1.0 - ((math.cos((kx + kx)) + math.cos((math.fabs(ky) + math.fabs(ky)))) * 0.5)))
	t_2 = math.sin(math.fabs(ky))
	t_3 = t_2 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_2, 2.0)))
	t_4 = -t_2
	tmp = 0
	if t_3 <= -1.0:
		tmp = (t_2 / math.fabs(t_2)) * math.sin(th)
	elif t_3 <= -0.1:
		tmp = t_4 * (1.0 / (t_1 / -th))
	elif t_3 <= 4.3e-21:
		tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx)))
	elif t_3 <= 0.98:
		tmp = t_4 * (th * (-1.0 / t_1))
	else:
		tmp = math.sin(th)
	return math.copysign(1.0, ky) * tmp
function code(kx, ky, th)
	t_1 = sqrt(Float64(1.0 - Float64(Float64(cos(Float64(kx + kx)) + cos(Float64(abs(ky) + abs(ky)))) * 0.5)))
	t_2 = sin(abs(ky))
	t_3 = Float64(t_2 / sqrt(Float64((sin(kx) ^ 2.0) + (t_2 ^ 2.0))))
	t_4 = Float64(-t_2)
	tmp = 0.0
	if (t_3 <= -1.0)
		tmp = Float64(Float64(t_2 / abs(t_2)) * sin(th));
	elseif (t_3 <= -0.1)
		tmp = Float64(t_4 * Float64(1.0 / Float64(t_1 / Float64(-th))));
	elseif (t_3 <= 4.3e-21)
		tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx))));
	elseif (t_3 <= 0.98)
		tmp = Float64(t_4 * Float64(th * Float64(-1.0 / t_1)));
	else
		tmp = sin(th);
	end
	return Float64(copysign(1.0, ky) * tmp)
end
function tmp_2 = code(kx, ky, th)
	t_1 = sqrt((1.0 - ((cos((kx + kx)) + cos((abs(ky) + abs(ky)))) * 0.5)));
	t_2 = sin(abs(ky));
	t_3 = t_2 / sqrt(((sin(kx) ^ 2.0) + (t_2 ^ 2.0)));
	t_4 = -t_2;
	tmp = 0.0;
	if (t_3 <= -1.0)
		tmp = (t_2 / abs(t_2)) * sin(th);
	elseif (t_3 <= -0.1)
		tmp = t_4 * (1.0 / (t_1 / -th));
	elseif (t_3 <= 4.3e-21)
		tmp = sin(th) * (abs(ky) / abs(sin(kx)));
	elseif (t_3 <= 0.98)
		tmp = t_4 * (th * (-1.0 / t_1));
	else
		tmp = sin(th);
	end
	tmp_2 = (sign(ky) * abs(1.0)) * tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[(1 - N[(N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$2, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = (-t$95$2)}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, -1], N[(N[(t$95$2 / N[Abs[t$95$2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -3602879701896397/36028797018963968], N[(t$95$4 * N[(1 / N[(t$95$1 / (-th)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2857840190937569/664613997892457936451903530140172288], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2206763817411543/2251799813685248], N[(t$95$4 * N[(th * N[(-1 / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]), $MachinePrecision]]]]]
\begin{array}{l}
t_1 := \sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}\\
t_2 := \sin \left(\left|ky\right|\right)\\
t_3 := \frac{t\_2}{\sqrt{{\sin kx}^{2} + {t\_2}^{2}}}\\
t_4 := -t\_2\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq -1:\\
\;\;\;\;\frac{t\_2}{\left|t\_2\right|} \cdot \sin th\\

\mathbf{elif}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_4 \cdot \frac{1}{\frac{t\_1}{-th}}\\

\mathbf{elif}\;t\_3 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\

\mathbf{elif}\;t\_3 \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;t\_4 \cdot \left(th \cdot \frac{-1}{t\_1}\right)\\

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


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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. mult-flipN/A

        \[\leadsto \left(\sin ky \cdot \sin th\right) \cdot \color{blue}{\frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lift-*.f64N/A

        \[\leadsto \left(\sin ky \cdot \sin th\right) \cdot \frac{\color{blue}{1}}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. *-commutativeN/A

        \[\leadsto \left(\sin th \cdot \sin ky\right) \cdot \frac{\color{blue}{1}}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      5. associate-*l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right)} \]
      6. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \color{blue}{\frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      8. lower-/.f6431.5%

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      9. lift-*.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      10. lift--.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      11. lift-cos.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      12. lift-*.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      13. cos-2N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \left(\cos ky \cdot \cos ky - \sin ky \cdot \sin ky\right)\right)}}\right) \]
      14. cos-sumN/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(ky + ky\right)\right)}}\right) \]
      15. lift-+.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(ky + ky\right)\right)}}\right) \]
      16. lift-cos.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(ky + ky\right)\right)}}\right) \]
      17. sub-flipN/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 + \left(\mathsf{neg}\left(\cos \left(ky + ky\right)\right)\right)\right)}}\right) \]
      18. distribute-lft-inN/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot 1 + \frac{1}{2} \cdot \left(\mathsf{neg}\left(\cos \left(ky + ky\right)\right)\right)}}\right) \]
    8. Applied rewrites31.5%

      \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right)} \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right) \cdot \color{blue}{\sin th} \]
      3. lower-*.f6431.5%

        \[\leadsto \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right) \cdot \color{blue}{\sin th} \]
    10. Applied rewrites45.5%

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Applied rewrites74.6%

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

      \[\leadsto \left(-\sin ky\right) \cdot \color{blue}{\left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \color{blue}{\frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      2. lower-/.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\color{blue}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      3. lower-sqrt.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      4. lower--.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      5. lower-+.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      6. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      7. lower-cos.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      8. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      10. lower-cos.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      11. lower-*.f6438.6%

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
    5. Applied rewrites38.6%

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

      \[\leadsto \left(-\sin ky\right) \cdot \frac{1}{\color{blue}{\frac{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}}{-th}}} \]

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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. div-flipN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      3. lower-unsound-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      4. lower-unsound-/.f6434.3%

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky \cdot \sin th}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky} \cdot \sin th}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\sin kx \cdot \sin kx}}{ky \cdot \sin th}} \]
      8. rem-sqrt-squareN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      9. lower-fabs.f6436.6%

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{ky \cdot \color{blue}{\sin th}}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\sin th \cdot \color{blue}{ky}}} \]
      12. lower-*.f6436.6%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{\sin th \cdot ky}}} \]
      3. div-flip-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\color{blue}{\left|\sin kx\right|}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\color{blue}{\sin kx}\right|} \]
      5. *-commutativeN/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\color{blue}{\sin kx}\right|} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      7. lift-fabs.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      8. rem-sqrt-square-revN/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\sin kx \cdot \sin kx}} \]
      9. unpow2N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      10. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      11. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{{\sin kx}^{2}}} \]
      14. unpow2N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\sin kx \cdot \sin kx}} \]
      15. rem-sqrt-square-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      16. lift-fabs.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      17. associate-/l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      18. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      19. lower-/.f6438.7%

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

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Applied rewrites74.6%

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

      \[\leadsto \left(-\sin ky\right) \cdot \color{blue}{\left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \color{blue}{\frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      2. lower-/.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\color{blue}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      3. lower-sqrt.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      4. lower--.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      5. lower-+.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      6. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      7. lower-cos.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      8. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      10. lower-cos.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      11. lower-*.f6438.6%

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
    5. Applied rewrites38.6%

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

      \[\leadsto \left(-\sin ky\right) \cdot \left(th \cdot \color{blue}{\frac{-1}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}}}\right) \]

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Taylor expanded in ky around 0

      \[\leadsto \sin th \]
    8. Step-by-step derivation
      1. lower-sin.f6424.3%

        \[\leadsto \sin th \]
    9. Applied rewrites24.3%

      \[\leadsto \sin th \]
  3. Recombined 5 regimes into one program.
  4. Add Preprocessing

Alternative 9: 82.5% accurate, 0.2× speedup?

\[\begin{array}{l} t_1 := \sin \left(\left|ky\right|\right)\\ t_2 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\ \mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l} \mathbf{if}\;t\_2 \leq -1:\\ \;\;\;\;\frac{t\_1}{\left|t\_1\right|} \cdot \sin th\\ \mathbf{elif}\;t\_2 \leq \frac{-3602879701896397}{36028797018963968}:\\ \;\;\;\;\frac{th \cdot t\_1}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot \left|ky\right|\right)\right)}}\\ \mathbf{elif}\;t\_2 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\ \;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\ \mathbf{elif}\;t\_2 \leq \frac{2206763817411543}{2251799813685248}:\\ \;\;\;\;\left(-t\_1\right) \cdot \left(th \cdot \frac{-1}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1 (sin (fabs ky)))
       (t_2 (/ t_1 (sqrt (+ (pow (sin kx) 2) (pow t_1 2))))))
  (*
   (copysign 1 ky)
   (if (<= t_2 -1)
     (* (/ t_1 (fabs t_1)) (sin th))
     (if (<= t_2 -3602879701896397/36028797018963968)
       (/
        (* th t_1)
        (sqrt
         (-
          1
          (+ (* 1/2 (cos (* 2 kx))) (* 1/2 (cos (* 2 (fabs ky))))))))
       (if (<=
            t_2
            2857840190937569/664613997892457936451903530140172288)
         (* (sin th) (/ (fabs ky) (fabs (sin kx))))
         (if (<= t_2 2206763817411543/2251799813685248)
           (*
            (- t_1)
            (*
             th
             (/
              -1
              (sqrt
               (-
                1
                (*
                 (+ (cos (+ kx kx)) (cos (+ (fabs ky) (fabs ky))))
                 1/2))))))
           (sin th))))))))
double code(double kx, double ky, double th) {
	double t_1 = sin(fabs(ky));
	double t_2 = t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)));
	double tmp;
	if (t_2 <= -1.0) {
		tmp = (t_1 / fabs(t_1)) * sin(th);
	} else if (t_2 <= -0.1) {
		tmp = (th * t_1) / sqrt((1.0 - ((0.5 * cos((2.0 * kx))) + (0.5 * cos((2.0 * fabs(ky)))))));
	} else if (t_2 <= 4.3e-21) {
		tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
	} else if (t_2 <= 0.98) {
		tmp = -t_1 * (th * (-1.0 / sqrt((1.0 - ((cos((kx + kx)) + cos((fabs(ky) + fabs(ky)))) * 0.5)))));
	} else {
		tmp = sin(th);
	}
	return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sin(Math.abs(ky));
	double t_2 = t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_1, 2.0)));
	double tmp;
	if (t_2 <= -1.0) {
		tmp = (t_1 / Math.abs(t_1)) * Math.sin(th);
	} else if (t_2 <= -0.1) {
		tmp = (th * t_1) / Math.sqrt((1.0 - ((0.5 * Math.cos((2.0 * kx))) + (0.5 * Math.cos((2.0 * Math.abs(ky)))))));
	} else if (t_2 <= 4.3e-21) {
		tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
	} else if (t_2 <= 0.98) {
		tmp = -t_1 * (th * (-1.0 / Math.sqrt((1.0 - ((Math.cos((kx + kx)) + Math.cos((Math.abs(ky) + Math.abs(ky)))) * 0.5)))));
	} else {
		tmp = Math.sin(th);
	}
	return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(math.fabs(ky))
	t_2 = t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_1, 2.0)))
	tmp = 0
	if t_2 <= -1.0:
		tmp = (t_1 / math.fabs(t_1)) * math.sin(th)
	elif t_2 <= -0.1:
		tmp = (th * t_1) / math.sqrt((1.0 - ((0.5 * math.cos((2.0 * kx))) + (0.5 * math.cos((2.0 * math.fabs(ky)))))))
	elif t_2 <= 4.3e-21:
		tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx)))
	elif t_2 <= 0.98:
		tmp = -t_1 * (th * (-1.0 / math.sqrt((1.0 - ((math.cos((kx + kx)) + math.cos((math.fabs(ky) + math.fabs(ky)))) * 0.5)))))
	else:
		tmp = math.sin(th)
	return math.copysign(1.0, ky) * tmp
function code(kx, ky, th)
	t_1 = sin(abs(ky))
	t_2 = Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0))))
	tmp = 0.0
	if (t_2 <= -1.0)
		tmp = Float64(Float64(t_1 / abs(t_1)) * sin(th));
	elseif (t_2 <= -0.1)
		tmp = Float64(Float64(th * t_1) / sqrt(Float64(1.0 - Float64(Float64(0.5 * cos(Float64(2.0 * kx))) + Float64(0.5 * cos(Float64(2.0 * abs(ky))))))));
	elseif (t_2 <= 4.3e-21)
		tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx))));
	elseif (t_2 <= 0.98)
		tmp = Float64(Float64(-t_1) * Float64(th * Float64(-1.0 / sqrt(Float64(1.0 - Float64(Float64(cos(Float64(kx + kx)) + cos(Float64(abs(ky) + abs(ky)))) * 0.5))))));
	else
		tmp = sin(th);
	end
	return Float64(copysign(1.0, ky) * tmp)
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(abs(ky));
	t_2 = t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0)));
	tmp = 0.0;
	if (t_2 <= -1.0)
		tmp = (t_1 / abs(t_1)) * sin(th);
	elseif (t_2 <= -0.1)
		tmp = (th * t_1) / sqrt((1.0 - ((0.5 * cos((2.0 * kx))) + (0.5 * cos((2.0 * abs(ky)))))));
	elseif (t_2 <= 4.3e-21)
		tmp = sin(th) * (abs(ky) / abs(sin(kx)));
	elseif (t_2 <= 0.98)
		tmp = -t_1 * (th * (-1.0 / sqrt((1.0 - ((cos((kx + kx)) + cos((abs(ky) + abs(ky)))) * 0.5)))));
	else
		tmp = sin(th);
	end
	tmp_2 = (sign(ky) * abs(1.0)) * tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, -1], N[(N[(t$95$1 / N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -3602879701896397/36028797018963968], N[(N[(th * t$95$1), $MachinePrecision] / N[Sqrt[N[(1 - N[(N[(1/2 * N[Cos[N[(2 * kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(1/2 * N[Cos[N[(2 * N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2857840190937569/664613997892457936451903530140172288], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2206763817411543/2251799813685248], N[((-t$95$1) * N[(th * N[(-1 / N[Sqrt[N[(1 - N[(N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]), $MachinePrecision]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -1:\\
\;\;\;\;\frac{t\_1}{\left|t\_1\right|} \cdot \sin th\\

\mathbf{elif}\;t\_2 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;\frac{th \cdot t\_1}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot \left|ky\right|\right)\right)}}\\

\mathbf{elif}\;t\_2 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\

\mathbf{elif}\;t\_2 \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;\left(-t\_1\right) \cdot \left(th \cdot \frac{-1}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}}\right)\\

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


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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. mult-flipN/A

        \[\leadsto \left(\sin ky \cdot \sin th\right) \cdot \color{blue}{\frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lift-*.f64N/A

        \[\leadsto \left(\sin ky \cdot \sin th\right) \cdot \frac{\color{blue}{1}}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. *-commutativeN/A

        \[\leadsto \left(\sin th \cdot \sin ky\right) \cdot \frac{\color{blue}{1}}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      5. associate-*l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right)} \]
      6. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \color{blue}{\frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      8. lower-/.f6431.5%

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      9. lift-*.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      10. lift--.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      11. lift-cos.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      12. lift-*.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      13. cos-2N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \left(\cos ky \cdot \cos ky - \sin ky \cdot \sin ky\right)\right)}}\right) \]
      14. cos-sumN/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(ky + ky\right)\right)}}\right) \]
      15. lift-+.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(ky + ky\right)\right)}}\right) \]
      16. lift-cos.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(ky + ky\right)\right)}}\right) \]
      17. sub-flipN/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 + \left(\mathsf{neg}\left(\cos \left(ky + ky\right)\right)\right)\right)}}\right) \]
      18. distribute-lft-inN/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot 1 + \frac{1}{2} \cdot \left(\mathsf{neg}\left(\cos \left(ky + ky\right)\right)\right)}}\right) \]
    8. Applied rewrites31.5%

      \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right)} \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right) \cdot \color{blue}{\sin th} \]
      3. lower-*.f6431.5%

        \[\leadsto \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right) \cdot \color{blue}{\sin th} \]
    10. Applied rewrites45.5%

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Applied rewrites74.6%

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

      \[\leadsto \color{blue}{\frac{th \cdot \sin ky}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{th \cdot \sin ky}{\color{blue}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{th \cdot \sin ky}{\sqrt{\color{blue}{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{th \cdot \sin ky}{\sqrt{1 - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{th \cdot \sin ky}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
      5. lower--.f64N/A

        \[\leadsto \frac{th \cdot \sin ky}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-+.f64N/A

        \[\leadsto \frac{th \cdot \sin ky}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower-*.f64N/A

        \[\leadsto \frac{th \cdot \sin ky}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{th \cdot \sin ky}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{th \cdot \sin ky}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{th \cdot \sin ky}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
      11. lower-cos.f64N/A

        \[\leadsto \frac{th \cdot \sin ky}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
      12. lower-*.f6438.5%

        \[\leadsto \frac{th \cdot \sin ky}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}} \]
    5. Applied rewrites38.5%

      \[\leadsto \color{blue}{\frac{th \cdot \sin ky}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}} \]

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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. div-flipN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      3. lower-unsound-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      4. lower-unsound-/.f6434.3%

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky \cdot \sin th}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky} \cdot \sin th}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\sin kx \cdot \sin kx}}{ky \cdot \sin th}} \]
      8. rem-sqrt-squareN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      9. lower-fabs.f6436.6%

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{ky \cdot \color{blue}{\sin th}}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\sin th \cdot \color{blue}{ky}}} \]
      12. lower-*.f6436.6%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{\sin th \cdot ky}}} \]
      3. div-flip-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\color{blue}{\left|\sin kx\right|}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\color{blue}{\sin kx}\right|} \]
      5. *-commutativeN/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\color{blue}{\sin kx}\right|} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      7. lift-fabs.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      8. rem-sqrt-square-revN/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\sin kx \cdot \sin kx}} \]
      9. unpow2N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      10. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      11. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{{\sin kx}^{2}}} \]
      14. unpow2N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\sin kx \cdot \sin kx}} \]
      15. rem-sqrt-square-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      16. lift-fabs.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      17. associate-/l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      18. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      19. lower-/.f6438.7%

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

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Applied rewrites74.6%

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

      \[\leadsto \left(-\sin ky\right) \cdot \color{blue}{\left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \color{blue}{\frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      2. lower-/.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\color{blue}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      3. lower-sqrt.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      4. lower--.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      5. lower-+.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      6. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      7. lower-cos.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      8. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      10. lower-cos.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      11. lower-*.f6438.6%

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
    5. Applied rewrites38.6%

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

      \[\leadsto \left(-\sin ky\right) \cdot \left(th \cdot \color{blue}{\frac{-1}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}}}\right) \]

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Taylor expanded in ky around 0

      \[\leadsto \sin th \]
    8. Step-by-step derivation
      1. lower-sin.f6424.3%

        \[\leadsto \sin th \]
    9. Applied rewrites24.3%

      \[\leadsto \sin th \]
  3. Recombined 5 regimes into one program.
  4. Add Preprocessing

Alternative 10: 82.5% accurate, 0.2× speedup?

\[\begin{array}{l} t_1 := \sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}\\ t_2 := \sin \left(\left|ky\right|\right)\\ t_3 := \frac{t\_2}{\sqrt{{\sin kx}^{2} + {t\_2}^{2}}}\\ \mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l} \mathbf{if}\;t\_3 \leq -1:\\ \;\;\;\;\frac{t\_2}{\left|t\_2\right|} \cdot \sin th\\ \mathbf{elif}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\ \;\;\;\;t\_2 \cdot \left(-\frac{-th}{t\_1}\right)\\ \mathbf{elif}\;t\_3 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\ \;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\ \mathbf{elif}\;t\_3 \leq \frac{2206763817411543}{2251799813685248}:\\ \;\;\;\;\left(-t\_2\right) \cdot \left(th \cdot \frac{-1}{t\_1}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1
        (sqrt
         (-
          1
          (* (+ (cos (+ kx kx)) (cos (+ (fabs ky) (fabs ky)))) 1/2))))
       (t_2 (sin (fabs ky)))
       (t_3 (/ t_2 (sqrt (+ (pow (sin kx) 2) (pow t_2 2))))))
  (*
   (copysign 1 ky)
   (if (<= t_3 -1)
     (* (/ t_2 (fabs t_2)) (sin th))
     (if (<= t_3 -3602879701896397/36028797018963968)
       (* t_2 (- (/ (- th) t_1)))
       (if (<=
            t_3
            2857840190937569/664613997892457936451903530140172288)
         (* (sin th) (/ (fabs ky) (fabs (sin kx))))
         (if (<= t_3 2206763817411543/2251799813685248)
           (* (- t_2) (* th (/ -1 t_1)))
           (sin th))))))))
double code(double kx, double ky, double th) {
	double t_1 = sqrt((1.0 - ((cos((kx + kx)) + cos((fabs(ky) + fabs(ky)))) * 0.5)));
	double t_2 = sin(fabs(ky));
	double t_3 = t_2 / sqrt((pow(sin(kx), 2.0) + pow(t_2, 2.0)));
	double tmp;
	if (t_3 <= -1.0) {
		tmp = (t_2 / fabs(t_2)) * sin(th);
	} else if (t_3 <= -0.1) {
		tmp = t_2 * -(-th / t_1);
	} else if (t_3 <= 4.3e-21) {
		tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
	} else if (t_3 <= 0.98) {
		tmp = -t_2 * (th * (-1.0 / t_1));
	} else {
		tmp = sin(th);
	}
	return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sqrt((1.0 - ((Math.cos((kx + kx)) + Math.cos((Math.abs(ky) + Math.abs(ky)))) * 0.5)));
	double t_2 = Math.sin(Math.abs(ky));
	double t_3 = t_2 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_2, 2.0)));
	double tmp;
	if (t_3 <= -1.0) {
		tmp = (t_2 / Math.abs(t_2)) * Math.sin(th);
	} else if (t_3 <= -0.1) {
		tmp = t_2 * -(-th / t_1);
	} else if (t_3 <= 4.3e-21) {
		tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
	} else if (t_3 <= 0.98) {
		tmp = -t_2 * (th * (-1.0 / t_1));
	} else {
		tmp = Math.sin(th);
	}
	return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th):
	t_1 = math.sqrt((1.0 - ((math.cos((kx + kx)) + math.cos((math.fabs(ky) + math.fabs(ky)))) * 0.5)))
	t_2 = math.sin(math.fabs(ky))
	t_3 = t_2 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_2, 2.0)))
	tmp = 0
	if t_3 <= -1.0:
		tmp = (t_2 / math.fabs(t_2)) * math.sin(th)
	elif t_3 <= -0.1:
		tmp = t_2 * -(-th / t_1)
	elif t_3 <= 4.3e-21:
		tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx)))
	elif t_3 <= 0.98:
		tmp = -t_2 * (th * (-1.0 / t_1))
	else:
		tmp = math.sin(th)
	return math.copysign(1.0, ky) * tmp
function code(kx, ky, th)
	t_1 = sqrt(Float64(1.0 - Float64(Float64(cos(Float64(kx + kx)) + cos(Float64(abs(ky) + abs(ky)))) * 0.5)))
	t_2 = sin(abs(ky))
	t_3 = Float64(t_2 / sqrt(Float64((sin(kx) ^ 2.0) + (t_2 ^ 2.0))))
	tmp = 0.0
	if (t_3 <= -1.0)
		tmp = Float64(Float64(t_2 / abs(t_2)) * sin(th));
	elseif (t_3 <= -0.1)
		tmp = Float64(t_2 * Float64(-Float64(Float64(-th) / t_1)));
	elseif (t_3 <= 4.3e-21)
		tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx))));
	elseif (t_3 <= 0.98)
		tmp = Float64(Float64(-t_2) * Float64(th * Float64(-1.0 / t_1)));
	else
		tmp = sin(th);
	end
	return Float64(copysign(1.0, ky) * tmp)
end
function tmp_2 = code(kx, ky, th)
	t_1 = sqrt((1.0 - ((cos((kx + kx)) + cos((abs(ky) + abs(ky)))) * 0.5)));
	t_2 = sin(abs(ky));
	t_3 = t_2 / sqrt(((sin(kx) ^ 2.0) + (t_2 ^ 2.0)));
	tmp = 0.0;
	if (t_3 <= -1.0)
		tmp = (t_2 / abs(t_2)) * sin(th);
	elseif (t_3 <= -0.1)
		tmp = t_2 * -(-th / t_1);
	elseif (t_3 <= 4.3e-21)
		tmp = sin(th) * (abs(ky) / abs(sin(kx)));
	elseif (t_3 <= 0.98)
		tmp = -t_2 * (th * (-1.0 / t_1));
	else
		tmp = sin(th);
	end
	tmp_2 = (sign(ky) * abs(1.0)) * tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[(1 - N[(N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$2, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, -1], N[(N[(t$95$2 / N[Abs[t$95$2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -3602879701896397/36028797018963968], N[(t$95$2 * (-N[((-th) / t$95$1), $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$3, 2857840190937569/664613997892457936451903530140172288], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2206763817411543/2251799813685248], N[((-t$95$2) * N[(th * N[(-1 / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}\\
t_2 := \sin \left(\left|ky\right|\right)\\
t_3 := \frac{t\_2}{\sqrt{{\sin kx}^{2} + {t\_2}^{2}}}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq -1:\\
\;\;\;\;\frac{t\_2}{\left|t\_2\right|} \cdot \sin th\\

\mathbf{elif}\;t\_3 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_2 \cdot \left(-\frac{-th}{t\_1}\right)\\

\mathbf{elif}\;t\_3 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\

\mathbf{elif}\;t\_3 \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;\left(-t\_2\right) \cdot \left(th \cdot \frac{-1}{t\_1}\right)\\

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


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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. mult-flipN/A

        \[\leadsto \left(\sin ky \cdot \sin th\right) \cdot \color{blue}{\frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lift-*.f64N/A

        \[\leadsto \left(\sin ky \cdot \sin th\right) \cdot \frac{\color{blue}{1}}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. *-commutativeN/A

        \[\leadsto \left(\sin th \cdot \sin ky\right) \cdot \frac{\color{blue}{1}}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      5. associate-*l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right)} \]
      6. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \color{blue}{\frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      8. lower-/.f6431.5%

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      9. lift-*.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      10. lift--.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      11. lift-cos.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      12. lift-*.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      13. cos-2N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \left(\cos ky \cdot \cos ky - \sin ky \cdot \sin ky\right)\right)}}\right) \]
      14. cos-sumN/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(ky + ky\right)\right)}}\right) \]
      15. lift-+.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(ky + ky\right)\right)}}\right) \]
      16. lift-cos.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(ky + ky\right)\right)}}\right) \]
      17. sub-flipN/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 + \left(\mathsf{neg}\left(\cos \left(ky + ky\right)\right)\right)\right)}}\right) \]
      18. distribute-lft-inN/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot 1 + \frac{1}{2} \cdot \left(\mathsf{neg}\left(\cos \left(ky + ky\right)\right)\right)}}\right) \]
    8. Applied rewrites31.5%

      \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right)} \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right) \cdot \color{blue}{\sin th} \]
      3. lower-*.f6431.5%

        \[\leadsto \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right) \cdot \color{blue}{\sin th} \]
    10. Applied rewrites45.5%

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Applied rewrites74.6%

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

      \[\leadsto \left(-\sin ky\right) \cdot \color{blue}{\left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \color{blue}{\frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      2. lower-/.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\color{blue}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      3. lower-sqrt.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      4. lower--.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      5. lower-+.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      6. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      7. lower-cos.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      8. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      10. lower-cos.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      11. lower-*.f6438.6%

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
    5. Applied rewrites38.6%

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

      \[\leadsto \color{blue}{\sin ky \cdot \left(-\frac{-th}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}}\right)} \]

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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. div-flipN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      3. lower-unsound-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      4. lower-unsound-/.f6434.3%

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky \cdot \sin th}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky} \cdot \sin th}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\sin kx \cdot \sin kx}}{ky \cdot \sin th}} \]
      8. rem-sqrt-squareN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      9. lower-fabs.f6436.6%

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{ky \cdot \color{blue}{\sin th}}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\sin th \cdot \color{blue}{ky}}} \]
      12. lower-*.f6436.6%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{\sin th \cdot ky}}} \]
      3. div-flip-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\color{blue}{\left|\sin kx\right|}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\color{blue}{\sin kx}\right|} \]
      5. *-commutativeN/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\color{blue}{\sin kx}\right|} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      7. lift-fabs.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      8. rem-sqrt-square-revN/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\sin kx \cdot \sin kx}} \]
      9. unpow2N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      10. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      11. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{{\sin kx}^{2}}} \]
      14. unpow2N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\sin kx \cdot \sin kx}} \]
      15. rem-sqrt-square-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      16. lift-fabs.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      17. associate-/l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      18. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      19. lower-/.f6438.7%

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

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Applied rewrites74.6%

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

      \[\leadsto \left(-\sin ky\right) \cdot \color{blue}{\left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \color{blue}{\frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      2. lower-/.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\color{blue}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      3. lower-sqrt.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      4. lower--.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      5. lower-+.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      6. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      7. lower-cos.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      8. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      10. lower-cos.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      11. lower-*.f6438.6%

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
    5. Applied rewrites38.6%

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

      \[\leadsto \left(-\sin ky\right) \cdot \left(th \cdot \color{blue}{\frac{-1}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}}}\right) \]

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Taylor expanded in ky around 0

      \[\leadsto \sin th \]
    8. Step-by-step derivation
      1. lower-sin.f6424.3%

        \[\leadsto \sin th \]
    9. Applied rewrites24.3%

      \[\leadsto \sin th \]
  3. Recombined 5 regimes into one program.
  4. Add Preprocessing

Alternative 11: 82.5% accurate, 0.2× speedup?

\[\begin{array}{l} t_1 := \sin \left(\left|ky\right|\right)\\ t_2 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\ t_3 := t\_1 \cdot \left(-\frac{-th}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}}\right)\\ \mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l} \mathbf{if}\;t\_2 \leq -1:\\ \;\;\;\;\frac{t\_1}{\left|t\_1\right|} \cdot \sin th\\ \mathbf{elif}\;t\_2 \leq \frac{-3602879701896397}{36028797018963968}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_2 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\ \;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\ \mathbf{elif}\;t\_2 \leq \frac{2206763817411543}{2251799813685248}:\\ \;\;\;\;t\_3\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1 (sin (fabs ky)))
       (t_2 (/ t_1 (sqrt (+ (pow (sin kx) 2) (pow t_1 2)))))
       (t_3
        (*
         t_1
         (-
          (/
           (- th)
           (sqrt
            (-
             1
             (*
              (+ (cos (+ kx kx)) (cos (+ (fabs ky) (fabs ky))))
              1/2))))))))
  (*
   (copysign 1 ky)
   (if (<= t_2 -1)
     (* (/ t_1 (fabs t_1)) (sin th))
     (if (<= t_2 -3602879701896397/36028797018963968)
       t_3
       (if (<=
            t_2
            2857840190937569/664613997892457936451903530140172288)
         (* (sin th) (/ (fabs ky) (fabs (sin kx))))
         (if (<= t_2 2206763817411543/2251799813685248)
           t_3
           (sin th))))))))
double code(double kx, double ky, double th) {
	double t_1 = sin(fabs(ky));
	double t_2 = t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)));
	double t_3 = t_1 * -(-th / sqrt((1.0 - ((cos((kx + kx)) + cos((fabs(ky) + fabs(ky)))) * 0.5))));
	double tmp;
	if (t_2 <= -1.0) {
		tmp = (t_1 / fabs(t_1)) * sin(th);
	} else if (t_2 <= -0.1) {
		tmp = t_3;
	} else if (t_2 <= 4.3e-21) {
		tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
	} else if (t_2 <= 0.98) {
		tmp = t_3;
	} else {
		tmp = sin(th);
	}
	return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sin(Math.abs(ky));
	double t_2 = t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_1, 2.0)));
	double t_3 = t_1 * -(-th / Math.sqrt((1.0 - ((Math.cos((kx + kx)) + Math.cos((Math.abs(ky) + Math.abs(ky)))) * 0.5))));
	double tmp;
	if (t_2 <= -1.0) {
		tmp = (t_1 / Math.abs(t_1)) * Math.sin(th);
	} else if (t_2 <= -0.1) {
		tmp = t_3;
	} else if (t_2 <= 4.3e-21) {
		tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
	} else if (t_2 <= 0.98) {
		tmp = t_3;
	} else {
		tmp = Math.sin(th);
	}
	return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(math.fabs(ky))
	t_2 = t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_1, 2.0)))
	t_3 = t_1 * -(-th / math.sqrt((1.0 - ((math.cos((kx + kx)) + math.cos((math.fabs(ky) + math.fabs(ky)))) * 0.5))))
	tmp = 0
	if t_2 <= -1.0:
		tmp = (t_1 / math.fabs(t_1)) * math.sin(th)
	elif t_2 <= -0.1:
		tmp = t_3
	elif t_2 <= 4.3e-21:
		tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx)))
	elif t_2 <= 0.98:
		tmp = t_3
	else:
		tmp = math.sin(th)
	return math.copysign(1.0, ky) * tmp
function code(kx, ky, th)
	t_1 = sin(abs(ky))
	t_2 = Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0))))
	t_3 = Float64(t_1 * Float64(-Float64(Float64(-th) / sqrt(Float64(1.0 - Float64(Float64(cos(Float64(kx + kx)) + cos(Float64(abs(ky) + abs(ky)))) * 0.5))))))
	tmp = 0.0
	if (t_2 <= -1.0)
		tmp = Float64(Float64(t_1 / abs(t_1)) * sin(th));
	elseif (t_2 <= -0.1)
		tmp = t_3;
	elseif (t_2 <= 4.3e-21)
		tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx))));
	elseif (t_2 <= 0.98)
		tmp = t_3;
	else
		tmp = sin(th);
	end
	return Float64(copysign(1.0, ky) * tmp)
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(abs(ky));
	t_2 = t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0)));
	t_3 = t_1 * -(-th / sqrt((1.0 - ((cos((kx + kx)) + cos((abs(ky) + abs(ky)))) * 0.5))));
	tmp = 0.0;
	if (t_2 <= -1.0)
		tmp = (t_1 / abs(t_1)) * sin(th);
	elseif (t_2 <= -0.1)
		tmp = t_3;
	elseif (t_2 <= 4.3e-21)
		tmp = sin(th) * (abs(ky) / abs(sin(kx)));
	elseif (t_2 <= 0.98)
		tmp = t_3;
	else
		tmp = sin(th);
	end
	tmp_2 = (sign(ky) * abs(1.0)) * tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * (-N[((-th) / N[Sqrt[N[(1 - N[(N[(N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(N[Abs[ky], $MachinePrecision] + N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, -1], N[(N[(t$95$1 / N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -3602879701896397/36028797018963968], t$95$3, If[LessEqual[t$95$2, 2857840190937569/664613997892457936451903530140172288], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2206763817411543/2251799813685248], t$95$3, N[Sin[th], $MachinePrecision]]]]]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\
t_3 := t\_1 \cdot \left(-\frac{-th}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(\left|ky\right| + \left|ky\right|\right)\right) \cdot \frac{1}{2}}}\right)\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -1:\\
\;\;\;\;\frac{t\_1}{\left|t\_1\right|} \cdot \sin th\\

\mathbf{elif}\;t\_2 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_2 \leq \frac{2857840190937569}{664613997892457936451903530140172288}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\

\mathbf{elif}\;t\_2 \leq \frac{2206763817411543}{2251799813685248}:\\
\;\;\;\;t\_3\\

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


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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. mult-flipN/A

        \[\leadsto \left(\sin ky \cdot \sin th\right) \cdot \color{blue}{\frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lift-*.f64N/A

        \[\leadsto \left(\sin ky \cdot \sin th\right) \cdot \frac{\color{blue}{1}}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. *-commutativeN/A

        \[\leadsto \left(\sin th \cdot \sin ky\right) \cdot \frac{\color{blue}{1}}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      5. associate-*l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right)} \]
      6. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \color{blue}{\frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      8. lower-/.f6431.5%

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      9. lift-*.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      10. lift--.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      11. lift-cos.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      12. lift-*.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      13. cos-2N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \left(\cos ky \cdot \cos ky - \sin ky \cdot \sin ky\right)\right)}}\right) \]
      14. cos-sumN/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(ky + ky\right)\right)}}\right) \]
      15. lift-+.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(ky + ky\right)\right)}}\right) \]
      16. lift-cos.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(ky + ky\right)\right)}}\right) \]
      17. sub-flipN/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 + \left(\mathsf{neg}\left(\cos \left(ky + ky\right)\right)\right)\right)}}\right) \]
      18. distribute-lft-inN/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot 1 + \frac{1}{2} \cdot \left(\mathsf{neg}\left(\cos \left(ky + ky\right)\right)\right)}}\right) \]
    8. Applied rewrites31.5%

      \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right)} \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right) \cdot \color{blue}{\sin th} \]
      3. lower-*.f6431.5%

        \[\leadsto \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right) \cdot \color{blue}{\sin th} \]
    10. Applied rewrites45.5%

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

    if -1 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < -0.10000000000000001 or 4.2999999999999998e-21 < (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) #s(literal 2 binary64)) (pow.f64 (sin.f64 ky) #s(literal 2 binary64))))) < 0.97999999999999998

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Applied rewrites74.6%

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

      \[\leadsto \left(-\sin ky\right) \cdot \color{blue}{\left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \color{blue}{\frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      2. lower-/.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\color{blue}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      3. lower-sqrt.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      4. lower--.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      5. lower-+.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      6. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      7. lower-cos.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      8. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      10. lower-cos.f64N/A

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
      11. lower-*.f6438.6%

        \[\leadsto \left(-\sin ky\right) \cdot \left(-1 \cdot \frac{th}{\sqrt{1 - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) + \frac{1}{2} \cdot \cos \left(2 \cdot ky\right)\right)}}\right) \]
    5. Applied rewrites38.6%

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

      \[\leadsto \color{blue}{\sin ky \cdot \left(-\frac{-th}{\sqrt{1 - \left(\cos \left(kx + kx\right) + \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}}\right)} \]

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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. div-flipN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      3. lower-unsound-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      4. lower-unsound-/.f6434.3%

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky \cdot \sin th}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky} \cdot \sin th}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\sin kx \cdot \sin kx}}{ky \cdot \sin th}} \]
      8. rem-sqrt-squareN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      9. lower-fabs.f6436.6%

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{ky \cdot \color{blue}{\sin th}}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\sin th \cdot \color{blue}{ky}}} \]
      12. lower-*.f6436.6%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{\sin th \cdot ky}}} \]
      3. div-flip-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\color{blue}{\left|\sin kx\right|}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\color{blue}{\sin kx}\right|} \]
      5. *-commutativeN/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\color{blue}{\sin kx}\right|} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      7. lift-fabs.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      8. rem-sqrt-square-revN/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\sin kx \cdot \sin kx}} \]
      9. unpow2N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      10. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      11. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{{\sin kx}^{2}}} \]
      14. unpow2N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\sin kx \cdot \sin kx}} \]
      15. rem-sqrt-square-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      16. lift-fabs.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      17. associate-/l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      18. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      19. lower-/.f6438.7%

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

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Taylor expanded in ky around 0

      \[\leadsto \sin th \]
    8. Step-by-step derivation
      1. lower-sin.f6424.3%

        \[\leadsto \sin th \]
    9. Applied rewrites24.3%

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

Alternative 12: 76.0% accurate, 0.5× speedup?

\[\begin{array}{l} t_1 := \frac{\sin ky}{\left|\sin ky\right|} \cdot \sin th\\ t_2 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ \mathbf{if}\;t\_2 \leq \frac{-3602879701896397}{36028797018963968}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq \frac{6646139978924579}{1329227995784915872903807060280344576}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\left|\sin kx\right|}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1 (* (/ (sin ky) (fabs (sin ky))) (sin th)))
       (t_2
        (/ (sin ky) (sqrt (+ (pow (sin kx) 2) (pow (sin ky) 2))))))
  (if (<= t_2 -3602879701896397/36028797018963968)
    t_1
    (if (<=
         t_2
         6646139978924579/1329227995784915872903807060280344576)
      (* (sin th) (/ ky (fabs (sin kx))))
      t_1))))
double code(double kx, double ky, double th) {
	double t_1 = (sin(ky) / fabs(sin(ky))) * sin(th);
	double t_2 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
	double tmp;
	if (t_2 <= -0.1) {
		tmp = t_1;
	} else if (t_2 <= 5e-21) {
		tmp = sin(th) * (ky / fabs(sin(kx)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(kx, ky, th)
use fmin_fmax_functions
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (sin(ky) / abs(sin(ky))) * sin(th)
    t_2 = sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))
    if (t_2 <= (-0.1d0)) then
        tmp = t_1
    else if (t_2 <= 5d-21) then
        tmp = sin(th) * (ky / abs(sin(kx)))
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double kx, double ky, double th) {
	double t_1 = (Math.sin(ky) / Math.abs(Math.sin(ky))) * Math.sin(th);
	double t_2 = Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)));
	double tmp;
	if (t_2 <= -0.1) {
		tmp = t_1;
	} else if (t_2 <= 5e-21) {
		tmp = Math.sin(th) * (ky / Math.abs(Math.sin(kx)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(kx, ky, th):
	t_1 = (math.sin(ky) / math.fabs(math.sin(ky))) * math.sin(th)
	t_2 = math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))
	tmp = 0
	if t_2 <= -0.1:
		tmp = t_1
	elif t_2 <= 5e-21:
		tmp = math.sin(th) * (ky / math.fabs(math.sin(kx)))
	else:
		tmp = t_1
	return tmp
function code(kx, ky, th)
	t_1 = Float64(Float64(sin(ky) / abs(sin(ky))) * sin(th))
	t_2 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))
	tmp = 0.0
	if (t_2 <= -0.1)
		tmp = t_1;
	elseif (t_2 <= 5e-21)
		tmp = Float64(sin(th) * Float64(ky / abs(sin(kx))));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(kx, ky, th)
	t_1 = (sin(ky) / abs(sin(ky))) * sin(th);
	t_2 = sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)));
	tmp = 0.0;
	if (t_2 <= -0.1)
		tmp = t_1;
	elseif (t_2 <= 5e-21)
		tmp = sin(th) * (ky / abs(sin(kx)));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -3602879701896397/36028797018963968], t$95$1, If[LessEqual[t$95$2, 6646139978924579/1329227995784915872903807060280344576], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_1 := \frac{\sin ky}{\left|\sin ky\right|} \cdot \sin th\\
t_2 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
\mathbf{if}\;t\_2 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_2 \leq \frac{6646139978924579}{1329227995784915872903807060280344576}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\left|\sin kx\right|}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. mult-flipN/A

        \[\leadsto \left(\sin ky \cdot \sin th\right) \cdot \color{blue}{\frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lift-*.f64N/A

        \[\leadsto \left(\sin ky \cdot \sin th\right) \cdot \frac{\color{blue}{1}}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. *-commutativeN/A

        \[\leadsto \left(\sin th \cdot \sin ky\right) \cdot \frac{\color{blue}{1}}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      5. associate-*l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right)} \]
      6. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \color{blue}{\frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      8. lower-/.f6431.5%

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}}\right) \]
      9. lift-*.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      10. lift--.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      11. lift-cos.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      12. lift-*.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}\right) \]
      13. cos-2N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \left(\cos ky \cdot \cos ky - \sin ky \cdot \sin ky\right)\right)}}\right) \]
      14. cos-sumN/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(ky + ky\right)\right)}}\right) \]
      15. lift-+.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(ky + ky\right)\right)}}\right) \]
      16. lift-cos.f64N/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(ky + ky\right)\right)}}\right) \]
      17. sub-flipN/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot \left(1 + \left(\mathsf{neg}\left(\cos \left(ky + ky\right)\right)\right)\right)}}\right) \]
      18. distribute-lft-inN/A

        \[\leadsto \sin th \cdot \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} \cdot 1 + \frac{1}{2} \cdot \left(\mathsf{neg}\left(\cos \left(ky + ky\right)\right)\right)}}\right) \]
    8. Applied rewrites31.5%

      \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right)} \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right) \cdot \color{blue}{\sin th} \]
      3. lower-*.f6431.5%

        \[\leadsto \left(\sin ky \cdot \frac{1}{\sqrt{\frac{1}{2} - \cos \left(ky + ky\right) \cdot \frac{1}{2}}}\right) \cdot \color{blue}{\sin th} \]
    10. Applied rewrites45.5%

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

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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. div-flipN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      3. lower-unsound-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      4. lower-unsound-/.f6434.3%

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky \cdot \sin th}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky} \cdot \sin th}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\sin kx \cdot \sin kx}}{ky \cdot \sin th}} \]
      8. rem-sqrt-squareN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      9. lower-fabs.f6436.6%

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{ky \cdot \color{blue}{\sin th}}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\sin th \cdot \color{blue}{ky}}} \]
      12. lower-*.f6436.6%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{\sin th \cdot ky}}} \]
      3. div-flip-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\color{blue}{\left|\sin kx\right|}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\color{blue}{\sin kx}\right|} \]
      5. *-commutativeN/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\color{blue}{\sin kx}\right|} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      7. lift-fabs.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      8. rem-sqrt-square-revN/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\sin kx \cdot \sin kx}} \]
      9. unpow2N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      10. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      11. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{{\sin kx}^{2}}} \]
      14. unpow2N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\sin kx \cdot \sin kx}} \]
      15. rem-sqrt-square-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      16. lift-fabs.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      17. associate-/l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      18. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      19. lower-/.f6438.7%

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

      \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 13: 67.8% accurate, 0.5× speedup?

\[\begin{array}{l} t_1 := \sin \left(\left|ky\right|\right)\\ t_2 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\ \mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l} \mathbf{if}\;t\_2 \leq \frac{-3602879701896397}{36028797018963968}:\\ \;\;\;\;\frac{th \cdot t\_1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot \left|ky\right|\right)\right)}}\\ \mathbf{elif}\;t\_2 \leq \frac{6646139978924579}{1329227995784915872903807060280344576}:\\ \;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1 (sin (fabs ky)))
       (t_2 (/ t_1 (sqrt (+ (pow (sin kx) 2) (pow t_1 2))))))
  (*
   (copysign 1 ky)
   (if (<= t_2 -3602879701896397/36028797018963968)
     (/ (* th t_1) (sqrt (* 1/2 (- 1 (cos (* 2 (fabs ky)))))))
     (if (<=
          t_2
          6646139978924579/1329227995784915872903807060280344576)
       (* (sin th) (/ (fabs ky) (fabs (sin kx))))
       (sin th))))))
double code(double kx, double ky, double th) {
	double t_1 = sin(fabs(ky));
	double t_2 = t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)));
	double tmp;
	if (t_2 <= -0.1) {
		tmp = (th * t_1) / sqrt((0.5 * (1.0 - cos((2.0 * fabs(ky))))));
	} else if (t_2 <= 5e-21) {
		tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
	} else {
		tmp = sin(th);
	}
	return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sin(Math.abs(ky));
	double t_2 = t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_1, 2.0)));
	double tmp;
	if (t_2 <= -0.1) {
		tmp = (th * t_1) / Math.sqrt((0.5 * (1.0 - Math.cos((2.0 * Math.abs(ky))))));
	} else if (t_2 <= 5e-21) {
		tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
	} else {
		tmp = Math.sin(th);
	}
	return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(math.fabs(ky))
	t_2 = t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_1, 2.0)))
	tmp = 0
	if t_2 <= -0.1:
		tmp = (th * t_1) / math.sqrt((0.5 * (1.0 - math.cos((2.0 * math.fabs(ky))))))
	elif t_2 <= 5e-21:
		tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx)))
	else:
		tmp = math.sin(th)
	return math.copysign(1.0, ky) * tmp
function code(kx, ky, th)
	t_1 = sin(abs(ky))
	t_2 = Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0))))
	tmp = 0.0
	if (t_2 <= -0.1)
		tmp = Float64(Float64(th * t_1) / sqrt(Float64(0.5 * Float64(1.0 - cos(Float64(2.0 * abs(ky)))))));
	elseif (t_2 <= 5e-21)
		tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx))));
	else
		tmp = sin(th);
	end
	return Float64(copysign(1.0, ky) * tmp)
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(abs(ky));
	t_2 = t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0)));
	tmp = 0.0;
	if (t_2 <= -0.1)
		tmp = (th * t_1) / sqrt((0.5 * (1.0 - cos((2.0 * abs(ky))))));
	elseif (t_2 <= 5e-21)
		tmp = sin(th) * (abs(ky) / abs(sin(kx)));
	else
		tmp = sin(th);
	end
	tmp_2 = (sign(ky) * abs(1.0)) * tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, -3602879701896397/36028797018963968], N[(N[(th * t$95$1), $MachinePrecision] / N[Sqrt[N[(1/2 * N[(1 - N[Cos[N[(2 * N[Abs[ky], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 6646139978924579/1329227995784915872903807060280344576], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]), $MachinePrecision]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := \frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq \frac{-3602879701896397}{36028797018963968}:\\
\;\;\;\;\frac{th \cdot t\_1}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot \left|ky\right|\right)\right)}}\\

\mathbf{elif}\;t\_2 \leq \frac{6646139978924579}{1329227995784915872903807060280344576}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\

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


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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Taylor expanded in th around 0

      \[\leadsto \frac{th \cdot \sin ky}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    8. Step-by-step derivation
      1. lower-*.f64N/A

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

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

      \[\leadsto \frac{th \cdot \sin ky}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]

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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. div-flipN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      3. lower-unsound-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      4. lower-unsound-/.f6434.3%

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky \cdot \sin th}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky} \cdot \sin th}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\sin kx \cdot \sin kx}}{ky \cdot \sin th}} \]
      8. rem-sqrt-squareN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      9. lower-fabs.f6436.6%

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{ky \cdot \color{blue}{\sin th}}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\sin th \cdot \color{blue}{ky}}} \]
      12. lower-*.f6436.6%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{\sin th \cdot ky}}} \]
      3. div-flip-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\color{blue}{\left|\sin kx\right|}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\color{blue}{\sin kx}\right|} \]
      5. *-commutativeN/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\color{blue}{\sin kx}\right|} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      7. lift-fabs.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      8. rem-sqrt-square-revN/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\sin kx \cdot \sin kx}} \]
      9. unpow2N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      10. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      11. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{{\sin kx}^{2}}} \]
      14. unpow2N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\sin kx \cdot \sin kx}} \]
      15. rem-sqrt-square-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      16. lift-fabs.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      17. associate-/l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      18. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      19. lower-/.f6438.7%

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

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Taylor expanded in ky around 0

      \[\leadsto \sin th \]
    8. Step-by-step derivation
      1. lower-sin.f6424.3%

        \[\leadsto \sin th \]
    9. Applied rewrites24.3%

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

Alternative 14: 60.5% accurate, 0.7× speedup?

\[\begin{array}{l} t_1 := \sin \left(\left|ky\right|\right)\\ \mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}} \leq \frac{6646139978924579}{1329227995784915872903807060280344576}:\\ \;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1 (sin (fabs ky))))
  (*
   (copysign 1 ky)
   (if (<=
        (/ t_1 (sqrt (+ (pow (sin kx) 2) (pow t_1 2))))
        6646139978924579/1329227995784915872903807060280344576)
     (* (sin th) (/ (fabs ky) (fabs (sin kx))))
     (sin th)))))
double code(double kx, double ky, double th) {
	double t_1 = sin(fabs(ky));
	double tmp;
	if ((t_1 / sqrt((pow(sin(kx), 2.0) + pow(t_1, 2.0)))) <= 5e-21) {
		tmp = sin(th) * (fabs(ky) / fabs(sin(kx)));
	} else {
		tmp = sin(th);
	}
	return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sin(Math.abs(ky));
	double tmp;
	if ((t_1 / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(t_1, 2.0)))) <= 5e-21) {
		tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(Math.sin(kx)));
	} else {
		tmp = Math.sin(th);
	}
	return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(math.fabs(ky))
	tmp = 0
	if (t_1 / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(t_1, 2.0)))) <= 5e-21:
		tmp = math.sin(th) * (math.fabs(ky) / math.fabs(math.sin(kx)))
	else:
		tmp = math.sin(th)
	return math.copysign(1.0, ky) * tmp
function code(kx, ky, th)
	t_1 = sin(abs(ky))
	tmp = 0.0
	if (Float64(t_1 / sqrt(Float64((sin(kx) ^ 2.0) + (t_1 ^ 2.0)))) <= 5e-21)
		tmp = Float64(sin(th) * Float64(abs(ky) / abs(sin(kx))));
	else
		tmp = sin(th);
	end
	return Float64(copysign(1.0, ky) * tmp)
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(abs(ky));
	tmp = 0.0;
	if ((t_1 / sqrt(((sin(kx) ^ 2.0) + (t_1 ^ 2.0)))) <= 5e-21)
		tmp = sin(th) * (abs(ky) / abs(sin(kx)));
	else
		tmp = sin(th);
	end
	tmp_2 = (sign(ky) * abs(1.0)) * tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 6646139978924579/1329227995784915872903807060280344576], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;\frac{t\_1}{\sqrt{{\sin kx}^{2} + {t\_1}^{2}}} \leq \frac{6646139978924579}{1329227995784915872903807060280344576}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|\sin kx\right|}\\

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


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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. div-flipN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      3. lower-unsound-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      4. lower-unsound-/.f6434.3%

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky \cdot \sin th}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky} \cdot \sin th}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\sin kx \cdot \sin kx}}{ky \cdot \sin th}} \]
      8. rem-sqrt-squareN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      9. lower-fabs.f6436.6%

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{ky \cdot \color{blue}{\sin th}}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\sin th \cdot \color{blue}{ky}}} \]
      12. lower-*.f6436.6%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\left|\sin kx\right|}{\sin th \cdot ky}}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{\sin th \cdot ky}}} \]
      3. div-flip-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\color{blue}{\left|\sin kx\right|}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\color{blue}{\sin kx}\right|} \]
      5. *-commutativeN/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\color{blue}{\sin kx}\right|} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      7. lift-fabs.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\left|\sin kx\right|} \]
      8. rem-sqrt-square-revN/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\sin kx \cdot \sin kx}} \]
      9. unpow2N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      10. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      11. lift-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      13. lift-sin.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{{\sin kx}^{2}}} \]
      14. unpow2N/A

        \[\leadsto \frac{\sin th \cdot ky}{\sqrt{\sin kx \cdot \sin kx}} \]
      15. rem-sqrt-square-revN/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      16. lift-fabs.f64N/A

        \[\leadsto \frac{\sin th \cdot ky}{\left|\sin kx\right|} \]
      17. associate-/l*N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      18. lower-*.f64N/A

        \[\leadsto \sin th \cdot \color{blue}{\frac{ky}{\left|\sin kx\right|}} \]
      19. lower-/.f6438.7%

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

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Taylor expanded in ky around 0

      \[\leadsto \sin th \]
    8. Step-by-step derivation
      1. lower-sin.f6424.3%

        \[\leadsto \sin th \]
    9. Applied rewrites24.3%

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

Alternative 15: 44.2% accurate, 0.5× speedup?

\[\begin{array}{l} t_1 := \sin \left(\left|ky\right|\right)\\ t_2 := \sin \left(\left|kx\right|\right)\\ t_3 := \frac{t\_1}{\sqrt{{t\_2}^{2} + {t\_1}^{2}}}\\ \mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l} \mathbf{if}\;t\_3 \leq \frac{8069530869021589}{20173827172553973356686868531273530268200826506478308693989526222973809547006571833044104322501076808092993531037089792}:\\ \;\;\;\;\frac{\left|ky\right| \cdot th}{\left|t\_2\right|}\\ \mathbf{elif}\;t\_3 \leq \frac{7136238463529799}{356811923176489970264571492362373784095686656}:\\ \;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|kx\right|}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1 (sin (fabs ky)))
       (t_2 (sin (fabs kx)))
       (t_3 (/ t_1 (sqrt (+ (pow t_2 2) (pow t_1 2))))))
  (*
   (copysign 1 ky)
   (if (<=
        t_3
        8069530869021589/20173827172553973356686868531273530268200826506478308693989526222973809547006571833044104322501076808092993531037089792)
     (/ (* (fabs ky) th) (fabs t_2))
     (if (<=
          t_3
          7136238463529799/356811923176489970264571492362373784095686656)
       (* (sin th) (/ (fabs ky) (fabs kx)))
       (sin th))))))
double code(double kx, double ky, double th) {
	double t_1 = sin(fabs(ky));
	double t_2 = sin(fabs(kx));
	double t_3 = t_1 / sqrt((pow(t_2, 2.0) + pow(t_1, 2.0)));
	double tmp;
	if (t_3 <= 4e-103) {
		tmp = (fabs(ky) * th) / fabs(t_2);
	} else if (t_3 <= 2e-29) {
		tmp = sin(th) * (fabs(ky) / fabs(kx));
	} else {
		tmp = sin(th);
	}
	return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sin(Math.abs(ky));
	double t_2 = Math.sin(Math.abs(kx));
	double t_3 = t_1 / Math.sqrt((Math.pow(t_2, 2.0) + Math.pow(t_1, 2.0)));
	double tmp;
	if (t_3 <= 4e-103) {
		tmp = (Math.abs(ky) * th) / Math.abs(t_2);
	} else if (t_3 <= 2e-29) {
		tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(kx));
	} else {
		tmp = Math.sin(th);
	}
	return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(math.fabs(ky))
	t_2 = math.sin(math.fabs(kx))
	t_3 = t_1 / math.sqrt((math.pow(t_2, 2.0) + math.pow(t_1, 2.0)))
	tmp = 0
	if t_3 <= 4e-103:
		tmp = (math.fabs(ky) * th) / math.fabs(t_2)
	elif t_3 <= 2e-29:
		tmp = math.sin(th) * (math.fabs(ky) / math.fabs(kx))
	else:
		tmp = math.sin(th)
	return math.copysign(1.0, ky) * tmp
function code(kx, ky, th)
	t_1 = sin(abs(ky))
	t_2 = sin(abs(kx))
	t_3 = Float64(t_1 / sqrt(Float64((t_2 ^ 2.0) + (t_1 ^ 2.0))))
	tmp = 0.0
	if (t_3 <= 4e-103)
		tmp = Float64(Float64(abs(ky) * th) / abs(t_2));
	elseif (t_3 <= 2e-29)
		tmp = Float64(sin(th) * Float64(abs(ky) / abs(kx)));
	else
		tmp = sin(th);
	end
	return Float64(copysign(1.0, ky) * tmp)
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(abs(ky));
	t_2 = sin(abs(kx));
	t_3 = t_1 / sqrt(((t_2 ^ 2.0) + (t_1 ^ 2.0)));
	tmp = 0.0;
	if (t_3 <= 4e-103)
		tmp = (abs(ky) * th) / abs(t_2);
	elseif (t_3 <= 2e-29)
		tmp = sin(th) * (abs(ky) / abs(kx));
	else
		tmp = sin(th);
	end
	tmp_2 = (sign(ky) * abs(1.0)) * tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[kx], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 / N[Sqrt[N[(N[Power[t$95$2, 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, 8069530869021589/20173827172553973356686868531273530268200826506478308693989526222973809547006571833044104322501076808092993531037089792], N[(N[(N[Abs[ky], $MachinePrecision] * th), $MachinePrecision] / N[Abs[t$95$2], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 7136238463529799/356811923176489970264571492362373784095686656], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
t_2 := \sin \left(\left|kx\right|\right)\\
t_3 := \frac{t\_1}{\sqrt{{t\_2}^{2} + {t\_1}^{2}}}\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq \frac{8069530869021589}{20173827172553973356686868531273530268200826506478308693989526222973809547006571833044104322501076808092993531037089792}:\\
\;\;\;\;\frac{\left|ky\right| \cdot th}{\left|t\_2\right|}\\

\mathbf{elif}\;t\_3 \leq \frac{7136238463529799}{356811923176489970264571492362373784095686656}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|kx\right|}\\

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


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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. div-flipN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      3. lower-unsound-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}}} \]
      4. lower-unsound-/.f6434.3%

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky \cdot \sin th}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{\color{blue}{ky} \cdot \sin th}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{\sqrt{{\sin kx}^{2}}}{ky \cdot \sin th}} \]
      7. unpow2N/A

        \[\leadsto \frac{1}{\frac{\sqrt{\sin kx \cdot \sin kx}}{ky \cdot \sin th}} \]
      8. rem-sqrt-squareN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      9. lower-fabs.f6436.6%

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\color{blue}{ky} \cdot \sin th}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{ky \cdot \color{blue}{\sin th}}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\left|\sin kx\right|}{\sin th \cdot \color{blue}{ky}}} \]
      12. lower-*.f6436.6%

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

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

      \[\leadsto \frac{ky \cdot th}{\color{blue}{\left|\sin kx\right|}} \]
    8. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot th}{\left|\sin kx\right|} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot th}{\left|\sin kx\right|} \]
      3. lower-fabs.f64N/A

        \[\leadsto \frac{ky \cdot th}{\left|\sin kx\right|} \]
      4. lower-sin.f6418.7%

        \[\leadsto \frac{ky \cdot th}{\left|\sin kx\right|} \]
    9. Applied rewrites18.7%

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

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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

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

      \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{kx}} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{kx} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{kx} \]
      3. lower-sin.f6415.8%

        \[\leadsto \frac{ky \cdot \sin th}{kx} \]
    7. Applied rewrites15.8%

      \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{kx}} \]
    8. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{kx} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{kx} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\sin th \cdot ky}{kx} \]
      4. associate-/l*N/A

        \[\leadsto \sin th \cdot \frac{ky}{\color{blue}{kx}} \]
      5. lower-*.f64N/A

        \[\leadsto \sin th \cdot \frac{ky}{\color{blue}{kx}} \]
      6. lower-/.f6416.5%

        \[\leadsto \sin th \cdot \frac{ky}{kx} \]
    9. Applied rewrites16.5%

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Taylor expanded in ky around 0

      \[\leadsto \sin th \]
    8. Step-by-step derivation
      1. lower-sin.f6424.3%

        \[\leadsto \sin th \]
    9. Applied rewrites24.3%

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

Alternative 16: 43.7% accurate, 0.8× speedup?

\[\begin{array}{l} t_1 := \sin \left(\left|ky\right|\right)\\ \mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{t\_1}{\sqrt{{\sin \left(\left|kx\right|\right)}^{2} + {t\_1}^{2}}} \leq \frac{7136238463529799}{356811923176489970264571492362373784095686656}:\\ \;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|kx\right|}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1 (sin (fabs ky))))
  (*
   (copysign 1 ky)
   (if (<=
        (/ t_1 (sqrt (+ (pow (sin (fabs kx)) 2) (pow t_1 2))))
        7136238463529799/356811923176489970264571492362373784095686656)
     (* (sin th) (/ (fabs ky) (fabs kx)))
     (sin th)))))
double code(double kx, double ky, double th) {
	double t_1 = sin(fabs(ky));
	double tmp;
	if ((t_1 / sqrt((pow(sin(fabs(kx)), 2.0) + pow(t_1, 2.0)))) <= 2e-29) {
		tmp = sin(th) * (fabs(ky) / fabs(kx));
	} else {
		tmp = sin(th);
	}
	return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sin(Math.abs(ky));
	double tmp;
	if ((t_1 / Math.sqrt((Math.pow(Math.sin(Math.abs(kx)), 2.0) + Math.pow(t_1, 2.0)))) <= 2e-29) {
		tmp = Math.sin(th) * (Math.abs(ky) / Math.abs(kx));
	} else {
		tmp = Math.sin(th);
	}
	return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(math.fabs(ky))
	tmp = 0
	if (t_1 / math.sqrt((math.pow(math.sin(math.fabs(kx)), 2.0) + math.pow(t_1, 2.0)))) <= 2e-29:
		tmp = math.sin(th) * (math.fabs(ky) / math.fabs(kx))
	else:
		tmp = math.sin(th)
	return math.copysign(1.0, ky) * tmp
function code(kx, ky, th)
	t_1 = sin(abs(ky))
	tmp = 0.0
	if (Float64(t_1 / sqrt(Float64((sin(abs(kx)) ^ 2.0) + (t_1 ^ 2.0)))) <= 2e-29)
		tmp = Float64(sin(th) * Float64(abs(ky) / abs(kx)));
	else
		tmp = sin(th);
	end
	return Float64(copysign(1.0, ky) * tmp)
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(abs(ky));
	tmp = 0.0;
	if ((t_1 / sqrt(((sin(abs(kx)) ^ 2.0) + (t_1 ^ 2.0)))) <= 2e-29)
		tmp = sin(th) * (abs(ky) / abs(kx));
	else
		tmp = sin(th);
	end
	tmp_2 = (sign(ky) * abs(1.0)) * tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[N[Abs[kx], $MachinePrecision]], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 7136238463529799/356811923176489970264571492362373784095686656], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[ky], $MachinePrecision] / N[Abs[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;\frac{t\_1}{\sqrt{{\sin \left(\left|kx\right|\right)}^{2} + {t\_1}^{2}}} \leq \frac{7136238463529799}{356811923176489970264571492362373784095686656}:\\
\;\;\;\;\sin th \cdot \frac{\left|ky\right|}{\left|kx\right|}\\

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


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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

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

      \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{kx}} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{kx} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{kx} \]
      3. lower-sin.f6415.8%

        \[\leadsto \frac{ky \cdot \sin th}{kx} \]
    7. Applied rewrites15.8%

      \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{kx}} \]
    8. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{kx} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{kx} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\sin th \cdot ky}{kx} \]
      4. associate-/l*N/A

        \[\leadsto \sin th \cdot \frac{ky}{\color{blue}{kx}} \]
      5. lower-*.f64N/A

        \[\leadsto \sin th \cdot \frac{ky}{\color{blue}{kx}} \]
      6. lower-/.f6416.5%

        \[\leadsto \sin th \cdot \frac{ky}{kx} \]
    9. Applied rewrites16.5%

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Taylor expanded in ky around 0

      \[\leadsto \sin th \]
    8. Step-by-step derivation
      1. lower-sin.f6424.3%

        \[\leadsto \sin th \]
    9. Applied rewrites24.3%

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

Alternative 17: 39.5% accurate, 0.8× speedup?

\[\begin{array}{l} t_1 := \sin \left(\left|ky\right|\right)\\ \mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{t\_1}{\sqrt{{\sin \left(\left|kx\right|\right)}^{2} + {t\_1}^{2}}} \leq \frac{7136238463529799}{356811923176489970264571492362373784095686656}:\\ \;\;\;\;\frac{\left|ky\right| \cdot th}{\left|kx\right|}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \end{array} \]
(FPCore (kx ky th)
  :precision binary64
  (let* ((t_1 (sin (fabs ky))))
  (*
   (copysign 1 ky)
   (if (<=
        (/ t_1 (sqrt (+ (pow (sin (fabs kx)) 2) (pow t_1 2))))
        7136238463529799/356811923176489970264571492362373784095686656)
     (/ (* (fabs ky) th) (fabs kx))
     (sin th)))))
double code(double kx, double ky, double th) {
	double t_1 = sin(fabs(ky));
	double tmp;
	if ((t_1 / sqrt((pow(sin(fabs(kx)), 2.0) + pow(t_1, 2.0)))) <= 2e-29) {
		tmp = (fabs(ky) * th) / fabs(kx);
	} else {
		tmp = sin(th);
	}
	return copysign(1.0, ky) * tmp;
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.sin(Math.abs(ky));
	double tmp;
	if ((t_1 / Math.sqrt((Math.pow(Math.sin(Math.abs(kx)), 2.0) + Math.pow(t_1, 2.0)))) <= 2e-29) {
		tmp = (Math.abs(ky) * th) / Math.abs(kx);
	} else {
		tmp = Math.sin(th);
	}
	return Math.copySign(1.0, ky) * tmp;
}
def code(kx, ky, th):
	t_1 = math.sin(math.fabs(ky))
	tmp = 0
	if (t_1 / math.sqrt((math.pow(math.sin(math.fabs(kx)), 2.0) + math.pow(t_1, 2.0)))) <= 2e-29:
		tmp = (math.fabs(ky) * th) / math.fabs(kx)
	else:
		tmp = math.sin(th)
	return math.copysign(1.0, ky) * tmp
function code(kx, ky, th)
	t_1 = sin(abs(ky))
	tmp = 0.0
	if (Float64(t_1 / sqrt(Float64((sin(abs(kx)) ^ 2.0) + (t_1 ^ 2.0)))) <= 2e-29)
		tmp = Float64(Float64(abs(ky) * th) / abs(kx));
	else
		tmp = sin(th);
	end
	return Float64(copysign(1.0, ky) * tmp)
end
function tmp_2 = code(kx, ky, th)
	t_1 = sin(abs(ky));
	tmp = 0.0;
	if ((t_1 / sqrt(((sin(abs(kx)) ^ 2.0) + (t_1 ^ 2.0)))) <= 2e-29)
		tmp = (abs(ky) * th) / abs(kx);
	else
		tmp = sin(th);
	end
	tmp_2 = (sign(ky) * abs(1.0)) * tmp;
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sin[N[Abs[ky], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[ky]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(t$95$1 / N[Sqrt[N[(N[Power[N[Sin[N[Abs[kx], $MachinePrecision]], $MachinePrecision], 2], $MachinePrecision] + N[Power[t$95$1, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 7136238463529799/356811923176489970264571492362373784095686656], N[(N[(N[Abs[ky], $MachinePrecision] * th), $MachinePrecision] / N[Abs[kx], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_1 := \sin \left(\left|ky\right|\right)\\
\mathsf{copysign}\left(1, ky\right) \cdot \begin{array}{l}
\mathbf{if}\;\frac{t\_1}{\sqrt{{\sin \left(\left|kx\right|\right)}^{2} + {t\_1}^{2}}} \leq \frac{7136238463529799}{356811923176489970264571492362373784095686656}:\\
\;\;\;\;\frac{\left|ky\right| \cdot th}{\left|kx\right|}\\

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


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

    1. Initial program 93.7%

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

      \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
      6. lower-sin.f6434.6%

        \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    4. Applied rewrites34.6%

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

      \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{kx}} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{kx} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{ky \cdot \sin th}{kx} \]
      3. lower-sin.f6415.8%

        \[\leadsto \frac{ky \cdot \sin th}{kx} \]
    7. Applied rewrites15.8%

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

      \[\leadsto \frac{ky \cdot th}{kx} \]
    9. Step-by-step derivation
      1. lower-*.f6412.3%

        \[\leadsto \frac{ky \cdot th}{kx} \]
    10. Applied rewrites12.3%

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

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

    1. Initial program 93.7%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{{\sin kx}^{2} + {\sin ky}^{2}}}} \cdot \sin th \]
      2. lift-pow.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx} \cdot \sin kx + {\sin ky}^{2}}} \cdot \sin th \]
      5. lift-sin.f64N/A

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

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

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      8. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      9. lower--.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \color{blue}{\left(\frac{1}{2} \cdot \cos \left(2 \cdot kx\right) - {\sin ky}^{2}\right)}}} \cdot \sin th \]
      10. count-2-revN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\frac{1}{2} \cdot \cos \color{blue}{\left(kx + kx\right)} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      11. *-commutativeN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\color{blue}{\cos \left(kx + kx\right) \cdot \frac{1}{2}} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      13. lower-cos.f64N/A

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

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \color{blue}{\left(kx + kx\right)} \cdot \frac{1}{2} - {\sin ky}^{2}\right)}} \cdot \sin th \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{{\sin ky}^{2}}\right)}} \cdot \sin th \]
      16. unpow2N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky \cdot \sin ky}\right)}} \cdot \sin th \]
      17. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\sin ky} \cdot \sin ky\right)}} \cdot \sin th \]
      18. lift-sin.f64N/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \sin ky \cdot \color{blue}{\sin ky}\right)}} \cdot \sin th \]
      19. sin-multN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\frac{\cos \left(ky - ky\right) - \cos \left(ky + ky\right)}{2}}\right)}} \cdot \sin th \]
      20. mult-flipN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \color{blue}{\left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \frac{1}{2}}\right)}} \cdot \sin th \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sin ky}{\sqrt{\frac{1}{2} - \left(\cos \left(kx + kx\right) \cdot \frac{1}{2} - \left(\cos \left(ky - ky\right) - \cos \left(ky + ky\right)\right) \cdot \color{blue}{\frac{1}{2}}\right)}} \cdot \sin th \]
      22. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\color{blue}{\frac{1}{2}} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      4. lower-sin.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \color{blue}{\left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      7. lower--.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
      9. lower-*.f6431.3%

        \[\leadsto \frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}} \]
    6. Applied rewrites31.3%

      \[\leadsto \color{blue}{\frac{\sin ky \cdot \sin th}{\sqrt{\frac{1}{2} \cdot \left(1 - \cos \left(2 \cdot ky\right)\right)}}} \]
    7. Taylor expanded in ky around 0

      \[\leadsto \sin th \]
    8. Step-by-step derivation
      1. lower-sin.f6424.3%

        \[\leadsto \sin th \]
    9. Applied rewrites24.3%

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

Alternative 18: 13.5% accurate, 33.3× speedup?

\[\frac{ky \cdot th}{\left|kx\right|} \]
(FPCore (kx ky th)
  :precision binary64
  (/ (* ky th) (fabs kx)))
double code(double kx, double ky, double th) {
	return (ky * th) / fabs(kx);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(kx, ky, th)
use fmin_fmax_functions
    real(8), intent (in) :: kx
    real(8), intent (in) :: ky
    real(8), intent (in) :: th
    code = (ky * th) / abs(kx)
end function
public static double code(double kx, double ky, double th) {
	return (ky * th) / Math.abs(kx);
}
def code(kx, ky, th):
	return (ky * th) / math.fabs(kx)
function code(kx, ky, th)
	return Float64(Float64(ky * th) / abs(kx))
end
function tmp = code(kx, ky, th)
	tmp = (ky * th) / abs(kx);
end
code[kx_, ky_, th_] := N[(N[(ky * th), $MachinePrecision] / N[Abs[kx], $MachinePrecision]), $MachinePrecision]
\frac{ky \cdot th}{\left|kx\right|}
Derivation
  1. Initial program 93.7%

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

    \[\leadsto \color{blue}{\frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}}} \]
  3. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{\sqrt{{\sin kx}^{2}}}} \]
    2. lower-*.f64N/A

      \[\leadsto \frac{ky \cdot \sin th}{\sqrt{\color{blue}{{\sin kx}^{2}}}} \]
    3. lower-sin.f64N/A

      \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{\color{blue}{2}}}} \]
    4. lower-sqrt.f64N/A

      \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    5. lower-pow.f64N/A

      \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
    6. lower-sin.f6434.6%

      \[\leadsto \frac{ky \cdot \sin th}{\sqrt{{\sin kx}^{2}}} \]
  4. Applied rewrites34.6%

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

    \[\leadsto \frac{ky \cdot \sin th}{\color{blue}{kx}} \]
  6. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \frac{ky \cdot \sin th}{kx} \]
    2. lower-*.f64N/A

      \[\leadsto \frac{ky \cdot \sin th}{kx} \]
    3. lower-sin.f6415.8%

      \[\leadsto \frac{ky \cdot \sin th}{kx} \]
  7. Applied rewrites15.8%

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

    \[\leadsto \frac{ky \cdot th}{kx} \]
  9. Step-by-step derivation
    1. lower-*.f6412.3%

      \[\leadsto \frac{ky \cdot th}{kx} \]
  10. Applied rewrites12.3%

    \[\leadsto \frac{ky \cdot th}{kx} \]
  11. Add Preprocessing

Reproduce

?
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (kx ky th)
  :name "Toniolo and Linder, Equation (3b), real"
  :precision binary64
  (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2) (pow (sin ky) 2)))) (sin th)))