Average Error: 3.9 → 4.2
Time: 10.8s
Precision: binary64
\[\frac{\sin ky}{\sqrt{{\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}}} \cdot \sin th\]
\[\begin{array}{l} \mathbf{if}\;kx \le -2.1002849544539553 \cdot 10^{-256}:\\ \;\;\;\;\left(\sqrt{\frac{1}{{\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}}} \cdot \sin ky\right) \cdot \sin th\\ \mathbf{elif}\;kx \le -1.87767470466880026 \cdot 10^{-272}:\\ \;\;\;\;\left(1 - \frac{1}{6} \cdot {kx}^{2}\right) \cdot \sin th\\ \mathbf{else}:\\ \;\;\;\;\left(\sin ky \cdot \frac{1}{\sqrt{{\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}}}\right) \cdot \sin th\\ \end{array}\]
\frac{\sin ky}{\sqrt{{\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}}} \cdot \sin th
\begin{array}{l}
\mathbf{if}\;kx \le -2.1002849544539553 \cdot 10^{-256}:\\
\;\;\;\;\left(\sqrt{\frac{1}{{\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}}} \cdot \sin ky\right) \cdot \sin th\\

\mathbf{elif}\;kx \le -1.87767470466880026 \cdot 10^{-272}:\\
\;\;\;\;\left(1 - \frac{1}{6} \cdot {kx}^{2}\right) \cdot \sin th\\

\mathbf{else}:\\
\;\;\;\;\left(\sin ky \cdot \frac{1}{\sqrt{{\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}}}\right) \cdot \sin th\\

\end{array}
double code(double kx, double ky, double th) {
	return ((double) (((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 ((kx <= -2.1002849544539553e-256)) {
		VAR = ((double) (((double) (((double) sqrt(((double) (1.0 / ((double) (((double) pow(((double) sin(kx)), 2.0)) + ((double) pow(((double) sin(ky)), 2.0)))))))) * ((double) sin(ky)))) * ((double) sin(th))));
	} else {
		double VAR_1;
		if ((kx <= -1.8776747046688003e-272)) {
			VAR_1 = ((double) (((double) (1.0 - ((double) (0.16666666666666666 * ((double) pow(kx, 2.0)))))) * ((double) sin(th))));
		} else {
			VAR_1 = ((double) (((double) (((double) sin(ky)) * ((double) (1.0 / ((double) sqrt(((double) (((double) pow(((double) sin(kx)), 2.0)) + ((double) pow(((double) sin(ky)), 2.0)))))))))) * ((double) sin(th))));
		}
		VAR = VAR_1;
	}
	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 3 regimes
  2. if kx < -2.1002849544539553e-256

    1. Initial program 2.9

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

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

    if -2.1002849544539553e-256 < kx < -1.87767470466880026e-272

    1. Initial program 18.6

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

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

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

    if -1.87767470466880026e-272 < kx

    1. Initial program 4.3

      \[\frac{\sin ky}{\sqrt{{\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}}} \cdot \sin th\]
    2. Using strategy rm
    3. Applied div-inv4.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;kx \le -2.1002849544539553 \cdot 10^{-256}:\\ \;\;\;\;\left(\sqrt{\frac{1}{{\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}}} \cdot \sin ky\right) \cdot \sin th\\ \mathbf{elif}\;kx \le -1.87767470466880026 \cdot 10^{-272}:\\ \;\;\;\;\left(1 - \frac{1}{6} \cdot {kx}^{2}\right) \cdot \sin th\\ \mathbf{else}:\\ \;\;\;\;\left(\sin ky \cdot \frac{1}{\sqrt{{\left(\sin kx\right)}^{2} + {\left(\sin ky\right)}^{2}}}\right) \cdot \sin th\\ \end{array}\]

Reproduce

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