Toniolo and Linder, Equation (3b), real

Percentage Accurate: 94.3% → 99.7%
Time: 6.6s
Alternatives: 7
Speedup: N/A×

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);
}
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.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 7 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.3% 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);
}
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.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, N/A× speedup?

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

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

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

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

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

      \[\leadsto \frac{\sin ky}{\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}} \cdot \sin th \]
    3. lower-hypot.f64N/A

      \[\leadsto \frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \color{blue}{\sin ky}\right)} \cdot \sin th \]
    4. lift-sin.f64N/A

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

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

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

Alternative 2: 99.5% accurate, N/A× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left({\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \sin ky\right) \cdot \sin th \]
    10. lift-sin.f64N/A

      \[\leadsto \left({\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \sin ky\right) \cdot \sin th \]
    11. lift-sin.f64N/A

      \[\leadsto \left({\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \sin ky\right) \cdot \sin th \]
    12. lift-sin.f6499.5

      \[\leadsto \left({\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \sin ky\right) \cdot \sin th \]
  5. Applied rewrites99.5%

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

Alternative 3: 97.6% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \log \left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right) \cdot -1\\ \left(\left(\cosh t\_1 + \sinh t\_1\right) \cdot \sin ky\right) \cdot \sin th \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (* (log (hypot (pow (sin ky) 1.0) (pow (sin kx) 1.0))) -1.0)))
   (* (* (+ (cosh t_1) (sinh t_1)) (sin ky)) (sin th))))
double code(double kx, double ky, double th) {
	double t_1 = log(hypot(pow(sin(ky), 1.0), pow(sin(kx), 1.0))) * -1.0;
	return ((cosh(t_1) + sinh(t_1)) * sin(ky)) * sin(th);
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.log(Math.hypot(Math.pow(Math.sin(ky), 1.0), Math.pow(Math.sin(kx), 1.0))) * -1.0;
	return ((Math.cosh(t_1) + Math.sinh(t_1)) * Math.sin(ky)) * Math.sin(th);
}
def code(kx, ky, th):
	t_1 = math.log(math.hypot(math.pow(math.sin(ky), 1.0), math.pow(math.sin(kx), 1.0))) * -1.0
	return ((math.cosh(t_1) + math.sinh(t_1)) * math.sin(ky)) * math.sin(th)
function code(kx, ky, th)
	t_1 = Float64(log(hypot((sin(ky) ^ 1.0), (sin(kx) ^ 1.0))) * -1.0)
	return Float64(Float64(Float64(cosh(t_1) + sinh(t_1)) * sin(ky)) * sin(th))
end
function tmp = code(kx, ky, th)
	t_1 = log(hypot((sin(ky) ^ 1.0), (sin(kx) ^ 1.0))) * -1.0;
	tmp = ((cosh(t_1) + sinh(t_1)) * sin(ky)) * sin(th);
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Log[N[Sqrt[N[Power[N[Sin[ky], $MachinePrecision], 1.0], $MachinePrecision] ^ 2 + N[Power[N[Sin[kx], $MachinePrecision], 1.0], $MachinePrecision] ^ 2], $MachinePrecision]], $MachinePrecision] * -1.0), $MachinePrecision]}, N[(N[(N[(N[Cosh[t$95$1], $MachinePrecision] + N[Sinh[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \log \left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right) \cdot -1\\
\left(\left(\cosh t\_1 + \sinh t\_1\right) \cdot \sin ky\right) \cdot \sin th
\end{array}
\end{array}
Derivation
  1. Initial program 95.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left({\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \sin ky\right) \cdot \sin th \]
    10. lift-sin.f64N/A

      \[\leadsto \left({\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \sin ky\right) \cdot \sin th \]
    11. lift-sin.f64N/A

      \[\leadsto \left({\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \sin ky\right) \cdot \sin th \]
    12. lift-sin.f6499.5

      \[\leadsto \left({\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \sin ky\right) \cdot \sin th \]
  5. Applied rewrites99.5%

    \[\leadsto \color{blue}{\left({\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \sin ky\right)} \cdot \sin th \]
  6. Step-by-step derivation
    1. lift-pow.f64N/A

      \[\leadsto \left({\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \sin \color{blue}{ky}\right) \cdot \sin th \]
    2. lift-sin.f64N/A

      \[\leadsto \left({\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \sin ky\right) \cdot \sin th \]
    3. lift-sin.f64N/A

      \[\leadsto \left({\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \sin ky\right) \cdot \sin th \]
    4. lift-hypot.f64N/A

      \[\leadsto \left({\left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right)}^{-1} \cdot \sin ky\right) \cdot \sin th \]
    5. pow-to-expN/A

      \[\leadsto \left(e^{\log \left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right) \cdot -1} \cdot \sin \color{blue}{ky}\right) \cdot \sin th \]
    6. sinh-+-cosh-revN/A

      \[\leadsto \left(\left(\cosh \left(\log \left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right) \cdot -1\right) + \sinh \left(\log \left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right) \cdot -1\right)\right) \cdot \sin \color{blue}{ky}\right) \cdot \sin th \]
    7. lower-+.f64N/A

      \[\leadsto \left(\left(\cosh \left(\log \left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right) \cdot -1\right) + \sinh \left(\log \left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right) \cdot -1\right)\right) \cdot \sin \color{blue}{ky}\right) \cdot \sin th \]
  7. Applied rewrites97.9%

    \[\leadsto \left(\left(\cosh \left(\log \left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right) \cdot -1\right) + \sinh \left(\log \left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right) \cdot -1\right)\right) \cdot \sin \color{blue}{ky}\right) \cdot \sin th \]
  8. Add Preprocessing

Alternative 4: 95.7% accurate, N/A× speedup?

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

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

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


\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

    1. Initial program 97.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin \color{blue}{ky} \cdot \sin th\right) \]
      10. lift-sin.f64N/A

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin ky \cdot \sin th\right) \]
      11. lift-sin.f64N/A

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin ky \cdot \sin th\right) \]
      12. *-commutativeN/A

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

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \color{blue}{\sin ky}\right) \]
      14. lift-sin.f64N/A

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin \color{blue}{ky}\right) \]
      15. lift-sin.f6495.6

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

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

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

    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)))))

    1. Initial program 3.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin \color{blue}{ky} \cdot \sin th\right) \]
      10. lift-sin.f64N/A

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin ky \cdot \sin th\right) \]
      11. lift-sin.f64N/A

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin ky \cdot \sin th\right) \]
      12. *-commutativeN/A

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

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \color{blue}{\sin ky}\right) \]
      14. lift-sin.f64N/A

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin \color{blue}{ky}\right) \]
      15. lift-sin.f6499.1

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin ky\right) \]
    5. Applied rewrites99.1%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin ky\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 95.5% accurate, N/A× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left({\left(\mathsf{hypot}\left(t\_2, {\sin kx}^{1}\right)\right)}^{-0.5} \cdot {\left(\mathsf{hypot}\left(t\_2, t\_1 \cdot t\_1\right)\right)}^{-0.5}\right) \cdot \left(\sin th \cdot \sin ky\right)\\


\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

    1. Initial program 97.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin \color{blue}{ky} \cdot \sin th\right) \]
      10. lift-sin.f64N/A

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin ky \cdot \sin th\right) \]
      11. lift-sin.f64N/A

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin ky \cdot \sin th\right) \]
      12. *-commutativeN/A

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

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \color{blue}{\sin ky}\right) \]
      14. lift-sin.f64N/A

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin \color{blue}{ky}\right) \]
      15. lift-sin.f6495.6

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

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

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

    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)))))

    1. Initial program 3.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin \color{blue}{ky} \cdot \sin th\right) \]
      10. lift-sin.f64N/A

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin ky \cdot \sin th\right) \]
      11. lift-sin.f64N/A

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin ky \cdot \sin th\right) \]
      12. *-commutativeN/A

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

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \color{blue}{\sin ky}\right) \]
      14. lift-sin.f64N/A

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin \color{blue}{ky}\right) \]
      15. lift-sin.f6499.1

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin ky\right) \]
    5. Applied rewrites99.1%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin ky\right)} \]
    6. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\color{blue}{\sin th} \cdot \sin ky\right) \]
      2. lift-sin.f64N/A

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin ky\right) \]
      3. lift-sin.f64N/A

        \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin ky\right) \]
      4. lift-hypot.f64N/A

        \[\leadsto {\left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right)}^{-1} \cdot \left(\sin \color{blue}{th} \cdot \sin ky\right) \]
      5. sqr-powN/A

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

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

      \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{-0.5} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{-0.5}\right) \cdot \left(\color{blue}{\sin th} \cdot \sin ky\right) \]
    8. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
      2. lift-sin.f64N/A

        \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
      3. sqr-powN/A

        \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{\left(\frac{1}{2}\right)} \cdot {\sin kx}^{\left(\frac{1}{2}\right)}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
      4. lower-*.f64N/A

        \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{\left(\frac{1}{2}\right)} \cdot {\sin kx}^{\left(\frac{1}{2}\right)}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
      5. metadata-evalN/A

        \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{\frac{1}{2}} \cdot {\sin kx}^{\left(\frac{1}{2}\right)}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
      6. lower-pow.f64N/A

        \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{\frac{1}{2}} \cdot {\sin kx}^{\left(\frac{1}{2}\right)}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
      7. lift-sin.f64N/A

        \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{\frac{1}{2}} \cdot {\sin kx}^{\left(\frac{1}{2}\right)}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
      8. metadata-evalN/A

        \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{\frac{1}{2}} \cdot {\sin kx}^{\frac{1}{2}}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
      9. lower-pow.f64N/A

        \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{\frac{1}{2}} \cdot {\sin kx}^{\frac{1}{2}}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
      10. lift-sin.f6478.8

        \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{-0.5} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{0.5} \cdot {\sin kx}^{0.5}\right)\right)}^{-0.5}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
    9. Applied rewrites78.8%

      \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{-0.5} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{0.5} \cdot {\sin kx}^{0.5}\right)\right)}^{-0.5}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 94.8% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{-0.5}\\ \left(t\_1 \cdot t\_1\right) \cdot \left(\sin th \cdot \sin ky\right) \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (pow (hypot (pow (sin ky) 1.0) (pow (sin kx) 1.0)) -0.5)))
   (* (* t_1 t_1) (* (sin th) (sin ky)))))
double code(double kx, double ky, double th) {
	double t_1 = pow(hypot(pow(sin(ky), 1.0), pow(sin(kx), 1.0)), -0.5);
	return (t_1 * t_1) * (sin(th) * sin(ky));
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.pow(Math.hypot(Math.pow(Math.sin(ky), 1.0), Math.pow(Math.sin(kx), 1.0)), -0.5);
	return (t_1 * t_1) * (Math.sin(th) * Math.sin(ky));
}
def code(kx, ky, th):
	t_1 = math.pow(math.hypot(math.pow(math.sin(ky), 1.0), math.pow(math.sin(kx), 1.0)), -0.5)
	return (t_1 * t_1) * (math.sin(th) * math.sin(ky))
function code(kx, ky, th)
	t_1 = hypot((sin(ky) ^ 1.0), (sin(kx) ^ 1.0)) ^ -0.5
	return Float64(Float64(t_1 * t_1) * Float64(sin(th) * sin(ky)))
end
function tmp = code(kx, ky, th)
	t_1 = hypot((sin(ky) ^ 1.0), (sin(kx) ^ 1.0)) ^ -0.5;
	tmp = (t_1 * t_1) * (sin(th) * sin(ky));
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sqrt[N[Power[N[Sin[ky], $MachinePrecision], 1.0], $MachinePrecision] ^ 2 + N[Power[N[Sin[kx], $MachinePrecision], 1.0], $MachinePrecision] ^ 2], $MachinePrecision], -0.5], $MachinePrecision]}, N[(N[(t$95$1 * t$95$1), $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{-0.5}\\
\left(t\_1 \cdot t\_1\right) \cdot \left(\sin th \cdot \sin ky\right)
\end{array}
\end{array}
Derivation
  1. Initial program 95.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin \color{blue}{ky} \cdot \sin th\right) \]
    10. lift-sin.f64N/A

      \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin ky \cdot \sin th\right) \]
    11. lift-sin.f64N/A

      \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin ky \cdot \sin th\right) \]
    12. *-commutativeN/A

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

      \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \color{blue}{\sin ky}\right) \]
    14. lift-sin.f64N/A

      \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin \color{blue}{ky}\right) \]
    15. lift-sin.f6495.6

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

    \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin ky\right)} \]
  6. Step-by-step derivation
    1. lift-pow.f64N/A

      \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\color{blue}{\sin th} \cdot \sin ky\right) \]
    2. lift-sin.f64N/A

      \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin ky\right) \]
    3. lift-sin.f64N/A

      \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin ky\right) \]
    4. lift-hypot.f64N/A

      \[\leadsto {\left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right)}^{-1} \cdot \left(\sin \color{blue}{th} \cdot \sin ky\right) \]
    5. sqr-powN/A

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

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

    \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{-0.5} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{-0.5}\right) \cdot \left(\color{blue}{\sin th} \cdot \sin ky\right) \]
  8. Add Preprocessing

Alternative 7: 47.1% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := {\sin kx}^{0.5}\\ t_2 := {\sin ky}^{1}\\ \left({\left(\mathsf{hypot}\left(t\_2, {\sin kx}^{1}\right)\right)}^{-0.5} \cdot {\left(\mathsf{hypot}\left(t\_2, t\_1 \cdot t\_1\right)\right)}^{-0.5}\right) \cdot \left(\sin th \cdot \sin ky\right) \end{array} \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (pow (sin kx) 0.5)) (t_2 (pow (sin ky) 1.0)))
   (*
    (*
     (pow (hypot t_2 (pow (sin kx) 1.0)) -0.5)
     (pow (hypot t_2 (* t_1 t_1)) -0.5))
    (* (sin th) (sin ky)))))
double code(double kx, double ky, double th) {
	double t_1 = pow(sin(kx), 0.5);
	double t_2 = pow(sin(ky), 1.0);
	return (pow(hypot(t_2, pow(sin(kx), 1.0)), -0.5) * pow(hypot(t_2, (t_1 * t_1)), -0.5)) * (sin(th) * sin(ky));
}
public static double code(double kx, double ky, double th) {
	double t_1 = Math.pow(Math.sin(kx), 0.5);
	double t_2 = Math.pow(Math.sin(ky), 1.0);
	return (Math.pow(Math.hypot(t_2, Math.pow(Math.sin(kx), 1.0)), -0.5) * Math.pow(Math.hypot(t_2, (t_1 * t_1)), -0.5)) * (Math.sin(th) * Math.sin(ky));
}
def code(kx, ky, th):
	t_1 = math.pow(math.sin(kx), 0.5)
	t_2 = math.pow(math.sin(ky), 1.0)
	return (math.pow(math.hypot(t_2, math.pow(math.sin(kx), 1.0)), -0.5) * math.pow(math.hypot(t_2, (t_1 * t_1)), -0.5)) * (math.sin(th) * math.sin(ky))
function code(kx, ky, th)
	t_1 = sin(kx) ^ 0.5
	t_2 = sin(ky) ^ 1.0
	return Float64(Float64((hypot(t_2, (sin(kx) ^ 1.0)) ^ -0.5) * (hypot(t_2, Float64(t_1 * t_1)) ^ -0.5)) * Float64(sin(th) * sin(ky)))
end
function tmp = code(kx, ky, th)
	t_1 = sin(kx) ^ 0.5;
	t_2 = sin(ky) ^ 1.0;
	tmp = ((hypot(t_2, (sin(kx) ^ 1.0)) ^ -0.5) * (hypot(t_2, (t_1 * t_1)) ^ -0.5)) * (sin(th) * sin(ky));
end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Power[N[Sin[kx], $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[ky], $MachinePrecision], 1.0], $MachinePrecision]}, N[(N[(N[Power[N[Sqrt[t$95$2 ^ 2 + N[Power[N[Sin[kx], $MachinePrecision], 1.0], $MachinePrecision] ^ 2], $MachinePrecision], -0.5], $MachinePrecision] * N[Power[N[Sqrt[t$95$2 ^ 2 + N[(t$95$1 * t$95$1), $MachinePrecision] ^ 2], $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] * N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := {\sin kx}^{0.5}\\
t_2 := {\sin ky}^{1}\\
\left({\left(\mathsf{hypot}\left(t\_2, {\sin kx}^{1}\right)\right)}^{-0.5} \cdot {\left(\mathsf{hypot}\left(t\_2, t\_1 \cdot t\_1\right)\right)}^{-0.5}\right) \cdot \left(\sin th \cdot \sin ky\right)
\end{array}
\end{array}
Derivation
  1. Initial program 95.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin \color{blue}{ky} \cdot \sin th\right) \]
    10. lift-sin.f64N/A

      \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin ky \cdot \sin th\right) \]
    11. lift-sin.f64N/A

      \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin ky \cdot \sin th\right) \]
    12. *-commutativeN/A

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

      \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \color{blue}{\sin ky}\right) \]
    14. lift-sin.f64N/A

      \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin \color{blue}{ky}\right) \]
    15. lift-sin.f6495.6

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

    \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin ky\right)} \]
  6. Step-by-step derivation
    1. lift-pow.f64N/A

      \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\color{blue}{\sin th} \cdot \sin ky\right) \]
    2. lift-sin.f64N/A

      \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin ky\right) \]
    3. lift-sin.f64N/A

      \[\leadsto {\left(\mathsf{hypot}\left(\sin kx, \sin ky\right)\right)}^{-1} \cdot \left(\sin th \cdot \sin ky\right) \]
    4. lift-hypot.f64N/A

      \[\leadsto {\left(\sqrt{\sin kx \cdot \sin kx + \sin ky \cdot \sin ky}\right)}^{-1} \cdot \left(\sin \color{blue}{th} \cdot \sin ky\right) \]
    5. sqr-powN/A

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

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

    \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{-0.5} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{-0.5}\right) \cdot \left(\color{blue}{\sin th} \cdot \sin ky\right) \]
  8. Step-by-step derivation
    1. lift-pow.f64N/A

      \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
    2. lift-sin.f64N/A

      \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
    3. sqr-powN/A

      \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{\left(\frac{1}{2}\right)} \cdot {\sin kx}^{\left(\frac{1}{2}\right)}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
    4. lower-*.f64N/A

      \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{\left(\frac{1}{2}\right)} \cdot {\sin kx}^{\left(\frac{1}{2}\right)}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
    5. metadata-evalN/A

      \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{\frac{1}{2}} \cdot {\sin kx}^{\left(\frac{1}{2}\right)}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
    6. lower-pow.f64N/A

      \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{\frac{1}{2}} \cdot {\sin kx}^{\left(\frac{1}{2}\right)}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
    7. lift-sin.f64N/A

      \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{\frac{1}{2}} \cdot {\sin kx}^{\left(\frac{1}{2}\right)}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
    8. metadata-evalN/A

      \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{\frac{1}{2}} \cdot {\sin kx}^{\frac{1}{2}}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
    9. lower-pow.f64N/A

      \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{\frac{-1}{2}} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{\frac{1}{2}} \cdot {\sin kx}^{\frac{1}{2}}\right)\right)}^{\frac{-1}{2}}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
    10. lift-sin.f6450.1

      \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{-0.5} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{0.5} \cdot {\sin kx}^{0.5}\right)\right)}^{-0.5}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
  9. Applied rewrites50.1%

    \[\leadsto \left({\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{1}\right)\right)}^{-0.5} \cdot {\left(\mathsf{hypot}\left({\sin ky}^{1}, {\sin kx}^{0.5} \cdot {\sin kx}^{0.5}\right)\right)}^{-0.5}\right) \cdot \left(\sin th \cdot \sin ky\right) \]
  10. Add Preprocessing

Reproduce

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