Average Error: 0.2 → 0.1
Time: 6.7s
Precision: binary64
\[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
\[\mathsf{fma}\left(1, \frac{1}{\sin B}, -\frac{x}{\tan B}\right) \]
(FPCore (B x)
 :precision binary64
 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
(FPCore (B x) :precision binary64 (fma 1.0 (/ 1.0 (sin B)) (- (/ x (tan B)))))
double code(double B, double x) {
	return -(x * (1.0 / tan(B))) + (1.0 / sin(B));
}
double code(double B, double x) {
	return fma(1.0, (1.0 / sin(B)), -(x / tan(B)));
}
function code(B, x)
	return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(1.0 / sin(B)))
end
function code(B, x)
	return fma(1.0, Float64(1.0 / sin(B)), Float64(-Float64(x / tan(B))))
end
code[B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[B_, x_] := N[(1.0 * N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] + (-N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}
\mathsf{fma}\left(1, \frac{1}{\sin B}, -\frac{x}{\tan B}\right)

Error

Bits error versus B

Bits error versus x

Derivation

  1. Initial program 0.2

    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
  2. Taylor expanded in x around 0 0.2

    \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x \cdot \cos B}{\sin B}} \]
  3. Applied egg-rr0.2

    \[\leadsto \color{blue}{\frac{1 - x \cdot \cos B}{\sin B}} \]
  4. Applied egg-rr0.1

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

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

Reproduce

herbie shell --seed 2022140 
(FPCore (B x)
  :name "VandenBroeck and Keller, Equation (24)"
  :precision binary64
  (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))