Average Error: 4.2 → 3.5
Time: 11.3s
Precision: binary64
\[\frac{\sin ky}{\sqrt{{\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}}} \cdot \sin th\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}}} \leq 1:\\ \;\;\;\;\sin ky \cdot \left(\sin th \cdot \sqrt{\frac{1}{{\left(\sin ky\right)}^{2} + {\left(\sin kx\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{ky + \left(kx \cdot \left(kx \cdot \left(ky \cdot 0.08333333333333333\right)\right) + {ky}^{3} \cdot -0.16666666666666666\right)}\\ \end{array}\]
\frac{\sin ky}{\sqrt{{\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}}} \cdot \sin th
\begin{array}{l}
\mathbf{if}\;\frac{\sin ky}{\sqrt{{\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}}} \leq 1:\\
\;\;\;\;\sin ky \cdot \left(\sin th \cdot \sqrt{\frac{1}{{\left(\sin ky\right)}^{2} + {\left(\sin kx\right)}^{2}}}\right)\\

\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{ky + \left(kx \cdot \left(kx \cdot \left(ky \cdot 0.08333333333333333\right)\right) + {ky}^{3} \cdot -0.16666666666666666\right)}\\

\end{array}
double code(double kx, double ky, double th) {
	return ((double) ((((double) sin(ky)) / ((double) sqrt(((double) (((double) pow(((double) sin(kx)), 2.0)) + ((double) pow(((double) sin(ky)), 2.0))))))) * ((double) sin(th))));
}
double code(double kx, double ky, double th) {
	double VAR;
	if (((((double) sin(ky)) / ((double) sqrt(((double) (((double) pow(((double) sin(kx)), 2.0)) + ((double) pow(((double) sin(ky)), 2.0))))))) <= 1.0)) {
		VAR = ((double) (((double) sin(ky)) * ((double) (((double) sin(th)) * ((double) sqrt((1.0 / ((double) (((double) pow(((double) sin(ky)), 2.0)) + ((double) pow(((double) sin(kx)), 2.0)))))))))));
	} else {
		VAR = ((double) (((double) sin(th)) * (((double) sin(ky)) / ((double) (ky + ((double) (((double) (kx * ((double) (kx * ((double) (ky * 0.08333333333333333)))))) + ((double) (((double) pow(ky, 3.0)) * -0.16666666666666666)))))))));
	}
	return VAR;
}

Error

Bits error versus kx

Bits error versus ky

Bits error versus th

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) < 1

    1. Initial program 2.4

      \[\frac{\sin ky}{\sqrt{{\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}}} \cdot \sin th\]
    2. Taylor expanded around inf 4.2

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

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

    if 1 < (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0))))

    1. Initial program 64.0

      \[\frac{\sin ky}{\sqrt{{\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}}} \cdot \sin th\]
    2. Taylor expanded around 0 29.3

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

      \[\leadsto \frac{\sin ky}{\color{blue}{ky + \left(kx \cdot \left(kx \cdot \left(ky \cdot 0.08333333333333333\right)\right) + {ky}^{3} \cdot -0.16666666666666666\right)}} \cdot \sin th\]
  3. Recombined 2 regimes into one program.
  4. Final simplification3.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin ky}{\sqrt{{\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}}} \leq 1:\\ \;\;\;\;\sin ky \cdot \left(\sin th \cdot \sqrt{\frac{1}{{\left(\sin ky\right)}^{2} + {\left(\sin kx\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{ky + \left(kx \cdot \left(kx \cdot \left(ky \cdot 0.08333333333333333\right)\right) + {ky}^{3} \cdot -0.16666666666666666\right)}\\ \end{array}\]

Reproduce

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