Average Error: 0.2 → 0.2
Time: 4.7s
Precision: 64
\[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}\]
\[\mathsf{fma}\left(-x, 1 \cdot \frac{\cos B}{\sin B}, \frac{1}{\sin B}\right)\]
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}
\mathsf{fma}\left(-x, 1 \cdot \frac{\cos B}{\sin B}, \frac{1}{\sin B}\right)
double code(double B, double x) {
	return (-(x * (1.0 / tan(B))) + (1.0 / sin(B)));
}
double code(double B, double x) {
	return fma(-x, (1.0 * (cos(B) / sin(B))), (1.0 / sin(B)));
}

Error

Bits error versus B

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.2

    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}\]
  2. Simplified0.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(-x, \frac{1}{\tan B}, \frac{1}{\sin B}\right)}\]
  3. Taylor expanded around inf 0.2

    \[\leadsto \mathsf{fma}\left(-x, \color{blue}{1 \cdot \frac{\cos B}{\sin B}}, \frac{1}{\sin B}\right)\]
  4. Final simplification0.2

    \[\leadsto \mathsf{fma}\left(-x, 1 \cdot \frac{\cos B}{\sin B}, \frac{1}{\sin B}\right)\]

Reproduce

herbie shell --seed 2020056 +o rules:numerics
(FPCore (B x)
  :name "VandenBroeck and Keller, Equation (24)"
  :precision binary64
  (+ (- (* x (/ 1 (tan B)))) (/ 1 (sin B))))