Toniolo and Linder, Equation (3b), real

Percentage Accurate: 94.0% → 99.7%
Time: 13.2s
Alternatives: 28
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 28 alternatives:

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

Initial Program: 94.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 67.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := 1 - \cos \left(kx \cdot -2\right)\\ t_2 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\ t_3 := \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)\\ \mathbf{if}\;t\_2 \leq -1:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{t\_3}}\\ \mathbf{elif}\;t\_2 \leq -0.2:\\ \;\;\;\;th \cdot \left(\sqrt{\frac{1}{\mathsf{fma}\left(0.5, t\_1, t\_3\right)}} \cdot \left(\sin ky \cdot \mathsf{fma}\left(-0.16666666666666666, th \cdot th, 1\right)\right)\right)\\ \mathbf{elif}\;t\_2 \leq 4 \cdot 10^{-144}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{t\_1} \cdot \sqrt{0.5}}\\ \mathbf{elif}\;t\_2 \leq 0.1:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{elif}\;t\_2 \leq 0.996:\\ \;\;\;\;\frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}{\sin ky \cdot \mathsf{fma}\left(th, \left(th \cdot th\right) \cdot \mathsf{fma}\left(0.008333333333333333, th \cdot th, -0.16666666666666666\right), th\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{fma}\left(kx, kx \cdot \frac{0.5}{ky}, \sin ky\right)}\\ \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (- 1.0 (cos (* kx -2.0))))
        (t_2 (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))))
        (t_3 (fma -0.5 (cos (* ky -2.0)) 0.5)))
   (if (<= t_2 -1.0)
     (* (sin th) (/ (sin ky) (sqrt t_3)))
     (if (<= t_2 -0.2)
       (*
        th
        (*
         (sqrt (/ 1.0 (fma 0.5 t_1 t_3)))
         (* (sin ky) (fma -0.16666666666666666 (* th th) 1.0))))
       (if (<= t_2 4e-144)
         (* (sin th) (/ (sin ky) (* (sqrt t_1) (sqrt 0.5))))
         (if (<= t_2 0.1)
           (* (sin th) (/ (sin ky) (sin kx)))
           (if (<= t_2 0.996)
             (/
              1.0
              (/
               (sqrt
                (fma
                 (- 1.0 (cos (+ kx kx)))
                 0.5
                 (+ 0.5 (* -0.5 (cos (+ ky ky))))))
               (*
                (sin ky)
                (fma
                 th
                 (*
                  (* th th)
                  (fma 0.008333333333333333 (* th th) -0.16666666666666666))
                 th))))
             (*
              (sin th)
              (/ (sin ky) (fma kx (* kx (/ 0.5 ky)) (sin ky)))))))))))
double code(double kx, double ky, double th) {
	double t_1 = 1.0 - cos((kx * -2.0));
	double t_2 = sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)));
	double t_3 = fma(-0.5, cos((ky * -2.0)), 0.5);
	double tmp;
	if (t_2 <= -1.0) {
		tmp = sin(th) * (sin(ky) / sqrt(t_3));
	} else if (t_2 <= -0.2) {
		tmp = th * (sqrt((1.0 / fma(0.5, t_1, t_3))) * (sin(ky) * fma(-0.16666666666666666, (th * th), 1.0)));
	} else if (t_2 <= 4e-144) {
		tmp = sin(th) * (sin(ky) / (sqrt(t_1) * sqrt(0.5)));
	} else if (t_2 <= 0.1) {
		tmp = sin(th) * (sin(ky) / sin(kx));
	} else if (t_2 <= 0.996) {
		tmp = 1.0 / (sqrt(fma((1.0 - cos((kx + kx))), 0.5, (0.5 + (-0.5 * cos((ky + ky)))))) / (sin(ky) * fma(th, ((th * th) * fma(0.008333333333333333, (th * th), -0.16666666666666666)), th)));
	} else {
		tmp = sin(th) * (sin(ky) / fma(kx, (kx * (0.5 / ky)), sin(ky)));
	}
	return tmp;
}
function code(kx, ky, th)
	t_1 = Float64(1.0 - cos(Float64(kx * -2.0)))
	t_2 = Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0))))
	t_3 = fma(-0.5, cos(Float64(ky * -2.0)), 0.5)
	tmp = 0.0
	if (t_2 <= -1.0)
		tmp = Float64(sin(th) * Float64(sin(ky) / sqrt(t_3)));
	elseif (t_2 <= -0.2)
		tmp = Float64(th * Float64(sqrt(Float64(1.0 / fma(0.5, t_1, t_3))) * Float64(sin(ky) * fma(-0.16666666666666666, Float64(th * th), 1.0))));
	elseif (t_2 <= 4e-144)
		tmp = Float64(sin(th) * Float64(sin(ky) / Float64(sqrt(t_1) * sqrt(0.5))));
	elseif (t_2 <= 0.1)
		tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx)));
	elseif (t_2 <= 0.996)
		tmp = Float64(1.0 / Float64(sqrt(fma(Float64(1.0 - cos(Float64(kx + kx))), 0.5, Float64(0.5 + Float64(-0.5 * cos(Float64(ky + ky)))))) / Float64(sin(ky) * fma(th, Float64(Float64(th * th) * fma(0.008333333333333333, Float64(th * th), -0.16666666666666666)), th))));
	else
		tmp = Float64(sin(th) * Float64(sin(ky) / fma(kx, Float64(kx * Float64(0.5 / ky)), sin(ky))));
	end
	return tmp
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(1.0 - N[Cos[N[(kx * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(-0.5 * N[Cos[N[(ky * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]}, If[LessEqual[t$95$2, -1.0], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -0.2], N[(th * N[(N[Sqrt[N[(1.0 / N[(0.5 * t$95$1 + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] * N[(-0.16666666666666666 * N[(th * th), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 4e-144], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[t$95$1], $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.1], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.996], N[(1.0 / N[(N[Sqrt[N[(N[(1.0 - N[Cos[N[(kx + kx), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(0.5 + N[(-0.5 * N[Cos[N[(ky + ky), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[ky], $MachinePrecision] * N[(th * N[(N[(th * th), $MachinePrecision] * N[(0.008333333333333333 * N[(th * th), $MachinePrecision] + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + th), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[(kx * N[(kx * N[(0.5 / ky), $MachinePrecision]), $MachinePrecision] + N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := 1 - \cos \left(kx \cdot -2\right)\\
t_2 := \frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}}\\
t_3 := \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)\\
\mathbf{if}\;t\_2 \leq -1:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{t\_3}}\\

\mathbf{elif}\;t\_2 \leq -0.2:\\
\;\;\;\;th \cdot \left(\sqrt{\frac{1}{\mathsf{fma}\left(0.5, t\_1, t\_3\right)}} \cdot \left(\sin ky \cdot \mathsf{fma}\left(-0.16666666666666666, th \cdot th, 1\right)\right)\right)\\

\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{-144}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{t\_1} \cdot \sqrt{0.5}}\\

\mathbf{elif}\;t\_2 \leq 0.1:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\

\mathbf{elif}\;t\_2 \leq 0.996:\\
\;\;\;\;\frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}{\sin ky \cdot \mathsf{fma}\left(th, \left(th \cdot th\right) \cdot \mathsf{fma}\left(0.008333333333333333, th \cdot th, -0.16666666666666666\right), th\right)}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 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 85.2%

      \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
    2. Add Preprocessing
    3. 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. clear-numN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sin th \cdot \sin ky\right) \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \cos \left(\mathsf{neg}\left(-2 \cdot ky\right)\right), \frac{1}{2}\right)}}} \]
      12. cos-negN/A

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

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

        \[\leadsto \left(\sin th \cdot \sin ky\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \cos \color{blue}{\left(ky \cdot -2\right)}, \frac{1}{2}\right)}} \]
      15. lower-*.f6461.2

        \[\leadsto \left(\sin th \cdot \sin ky\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \color{blue}{\left(ky \cdot -2\right)}, 0.5\right)}} \]
    7. Applied rewrites61.2%

      \[\leadsto \color{blue}{\left(\sin th \cdot \sin ky\right) \cdot \sqrt{\frac{1}{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}} \]
    8. Step-by-step derivation
      1. Applied rewrites61.5%

        \[\leadsto \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\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.20000000000000001

      1. Initial program 99.2%

        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
      2. Add Preprocessing
      3. 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. clear-numN/A

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

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

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

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

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

        \[\leadsto \color{blue}{th \cdot \left(\sqrt{\frac{1}{\mathsf{fma}\left(0.5, 1 - \cos \left(kx \cdot -2\right), \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)\right)}} \cdot \left(\mathsf{fma}\left(-0.16666666666666666, th \cdot th, 1\right) \cdot \sin ky\right)\right)} \]

      if -0.20000000000000001 < (/.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-144

      1. Initial program 99.4%

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

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

          \[\leadsto \frac{\sin ky}{\sqrt{\color{blue}{\sin kx \cdot \sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
        3. lift-sin.f64N/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{\sin kx \cdot \color{blue}{\sin kx} + {\sin ky}^{2}}} \cdot \sin th \]
        5. sin-multN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\sin ky}{\sqrt{1 - \cos \color{blue}{\left(kx \cdot -2\right)}} \cdot \sqrt{\frac{1}{2}}} \cdot \sin th \]
        11. lower-sqrt.f6473.0

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

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

      if 3.9999999999999998e-144 < (/.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 98.9%

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

        \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
      4. Step-by-step derivation
        1. lower-sin.f6452.6

          \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \sin th \]
      5. Applied rewrites52.6%

        \[\leadsto \frac{\sin ky}{\color{blue}{\sin kx}} \cdot \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))))) < 0.996

      1. Initial program 99.2%

        \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
      2. Add Preprocessing
      3. 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. clear-numN/A

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

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

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

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

        \[\leadsto \frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(ky + ky\right)\right)}}{\sin ky \cdot \color{blue}{\left(th \cdot \left(1 + {th}^{2} \cdot \left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}\right)\right)\right)}}} \]
      6. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(ky + ky\right)\right)}}{\sin ky \cdot \left(th \cdot \color{blue}{\left({th}^{2} \cdot \left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}\right) + 1\right)}\right)}} \]
        2. distribute-lft-inN/A

          \[\leadsto \frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(ky + ky\right)\right)}}{\sin ky \cdot \color{blue}{\left(th \cdot \left({th}^{2} \cdot \left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}\right)\right) + th \cdot 1\right)}}} \]
        3. *-rgt-identityN/A

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

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

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

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

          \[\leadsto \frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(ky + ky\right)\right)}}{\sin ky \cdot \mathsf{fma}\left(th, \color{blue}{\left(th \cdot th\right)} \cdot \left(\frac{1}{120} \cdot {th}^{2} - \frac{1}{6}\right), th\right)}} \]
        8. sub-negN/A

          \[\leadsto \frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(ky + ky\right)\right)}}{\sin ky \cdot \mathsf{fma}\left(th, \left(th \cdot th\right) \cdot \color{blue}{\left(\frac{1}{120} \cdot {th}^{2} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)\right)}, th\right)}} \]
        9. metadata-evalN/A

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

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

          \[\leadsto \frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), \frac{1}{2}, \frac{1}{2} + \frac{-1}{2} \cdot \cos \left(ky + ky\right)\right)}}{\sin ky \cdot \mathsf{fma}\left(th, \left(th \cdot th\right) \cdot \mathsf{fma}\left(\frac{1}{120}, \color{blue}{th \cdot th}, \frac{-1}{6}\right), th\right)}} \]
        12. lower-*.f6451.2

          \[\leadsto \frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}{\sin ky \cdot \mathsf{fma}\left(th, \left(th \cdot th\right) \cdot \mathsf{fma}\left(0.008333333333333333, \color{blue}{th \cdot th}, -0.16666666666666666\right), th\right)}} \]
      7. Applied rewrites51.2%

        \[\leadsto \frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}{\sin ky \cdot \color{blue}{\mathsf{fma}\left(th, \left(th \cdot th\right) \cdot \mathsf{fma}\left(0.008333333333333333, th \cdot th, -0.16666666666666666\right), th\right)}}} \]

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

      1. Initial program 87.7%

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

        \[\leadsto \frac{\sin ky}{\color{blue}{\sin ky + \frac{1}{2} \cdot \frac{{kx}^{2}}{\sin ky}}} \cdot \sin th \]
      4. Step-by-step derivation
        1. +-commutativeN/A

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

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

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

          \[\leadsto \frac{\sin ky}{\color{blue}{{kx}^{2} \cdot \frac{\frac{1}{2}}{\sin ky}} + \sin ky} \cdot \sin th \]
        5. metadata-evalN/A

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

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

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

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

          \[\leadsto \frac{\sin ky}{\color{blue}{\mathsf{fma}\left(kx, kx \cdot \left(\frac{1}{2} \cdot \frac{1}{\sin ky}\right), \sin ky\right)}} \cdot \sin th \]
        10. lower-*.f64N/A

          \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(kx, \color{blue}{kx \cdot \left(\frac{1}{2} \cdot \frac{1}{\sin ky}\right)}, \sin ky\right)} \cdot \sin th \]
        11. associate-*r/N/A

          \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(kx, kx \cdot \color{blue}{\frac{\frac{1}{2} \cdot 1}{\sin ky}}, \sin ky\right)} \cdot \sin th \]
        12. metadata-evalN/A

          \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(kx, kx \cdot \frac{\color{blue}{\frac{1}{2}}}{\sin ky}, \sin ky\right)} \cdot \sin th \]
        13. lower-/.f64N/A

          \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(kx, kx \cdot \color{blue}{\frac{\frac{1}{2}}{\sin ky}}, \sin ky\right)} \cdot \sin th \]
        14. lower-sin.f64N/A

          \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(kx, kx \cdot \frac{\frac{1}{2}}{\color{blue}{\sin ky}}, \sin ky\right)} \cdot \sin th \]
        15. lower-sin.f6491.1

          \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(kx, kx \cdot \frac{0.5}{\sin ky}, \color{blue}{\sin ky}\right)} \cdot \sin th \]
      5. Applied rewrites91.1%

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

        \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(kx, kx \cdot \frac{\frac{1}{2}}{\color{blue}{ky}}, \sin ky\right)} \cdot \sin th \]
      7. Step-by-step derivation
        1. Applied rewrites90.9%

          \[\leadsto \frac{\sin ky}{\mathsf{fma}\left(kx, kx \cdot \frac{0.5}{\color{blue}{ky}}, \sin ky\right)} \cdot \sin th \]
      8. Recombined 6 regimes into one program.
      9. Final simplification67.5%

        \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -1:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{\mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq -0.2:\\ \;\;\;\;th \cdot \left(\sqrt{\frac{1}{\mathsf{fma}\left(0.5, 1 - \cos \left(kx \cdot -2\right), \mathsf{fma}\left(-0.5, \cos \left(ky \cdot -2\right), 0.5\right)\right)}} \cdot \left(\sin ky \cdot \mathsf{fma}\left(-0.16666666666666666, th \cdot th, 1\right)\right)\right)\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 4 \cdot 10^{-144}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sqrt{1 - \cos \left(kx \cdot -2\right)} \cdot \sqrt{0.5}}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.1:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{elif}\;\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \leq 0.996:\\ \;\;\;\;\frac{1}{\frac{\sqrt{\mathsf{fma}\left(1 - \cos \left(kx + kx\right), 0.5, 0.5 + -0.5 \cdot \cos \left(ky + ky\right)\right)}}{\sin ky \cdot \mathsf{fma}\left(th, \left(th \cdot th\right) \cdot \mathsf{fma}\left(0.008333333333333333, th \cdot th, -0.16666666666666666\right), th\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{fma}\left(kx, kx \cdot \frac{0.5}{ky}, \sin ky\right)}\\ \end{array} \]
      10. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2024226 
      (FPCore (kx ky th)
        :name "Toniolo and Linder, Equation (3b), real"
        :precision binary64
        (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))