Average Error: 4.4 → 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:\\ \;\;\;\;\left(\sin ky \cdot {\left({\left(\sin ky\right)}^{2} + {\left(\sin kx\right)}^{2}\right)}^{-0.5}\right) \cdot \sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\left(ky + 0.08333333333333333 \cdot \left(ky \cdot \left(kx \cdot kx\right)\right)\right) - 0.16666666666666666 \cdot {ky}^{3}}\\ \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:\\
\;\;\;\;\left(\sin ky \cdot {\left({\left(\sin ky\right)}^{2} + {\left(\sin kx\right)}^{2}\right)}^{-0.5}\right) \cdot \sin th\\

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

\end{array}
(FPCore (kx ky th)
 :precision binary64
 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
(FPCore (kx ky th)
 :precision binary64
 (if (<= (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) 1.0)
   (*
    (* (sin ky) (pow (+ (pow (sin ky) 2.0) (pow (sin kx) 2.0)) -0.5))
    (sin th))
   (*
    (sin th)
    (/
     (sin ky)
     (-
      (+ ky (* 0.08333333333333333 (* ky (* kx kx))))
      (* 0.16666666666666666 (pow ky 3.0)))))))
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 tmp;
	if (((((double) sin(ky)) / ((double) sqrt(((double) (((double) pow(((double) sin(kx)), 2.0)) + ((double) pow(((double) sin(ky)), 2.0))))))) <= 1.0)) {
		tmp = ((double) (((double) (((double) sin(ky)) * ((double) pow(((double) (((double) pow(((double) sin(ky)), 2.0)) + ((double) pow(((double) sin(kx)), 2.0)))), -0.5)))) * ((double) sin(th))));
	} else {
		tmp = ((double) (((double) sin(th)) * (((double) sin(ky)) / ((double) (((double) (ky + ((double) (0.08333333333333333 * ((double) (ky * ((double) (kx * kx)))))))) - ((double) (0.16666666666666666 * ((double) pow(ky, 3.0)))))))));
	}
	return tmp;
}

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 (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) 2.0) (pow.f64 (sin.f64 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 2.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. Simplified2.7

      \[\leadsto \color{blue}{\left(\sin ky \cdot \sqrt{\frac{1}{{\left(\sin ky\right)}^{2} + {\left(\sin kx\right)}^{2}}}\right)} \cdot \sin th\]
    4. Using strategy rm
    5. Applied inv-pow_binary642.7

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

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

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

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

    1. Initial program 63.0

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

      \[\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. Simplified32.1

      \[\leadsto \frac{\sin ky}{\color{blue}{\left(ky + 0.08333333333333333 \cdot \left(ky \cdot \left(kx \cdot kx\right)\right)\right) - 0.16666666666666666 \cdot {ky}^{3}}} \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:\\ \;\;\;\;\left(\sin ky \cdot {\left({\left(\sin ky\right)}^{2} + {\left(\sin kx\right)}^{2}\right)}^{-0.5}\right) \cdot \sin th\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\left(ky + 0.08333333333333333 \cdot \left(ky \cdot \left(kx \cdot kx\right)\right)\right) - 0.16666666666666666 \cdot {ky}^{3}}\\ \end{array}\]

Reproduce

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