Average Error: 0.0 → 0.5
Time: 3.0s
Precision: binary64
\[\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right) \]
\[\log 2 - \mathsf{fma}\left(x \cdot x, 0.25, \log x\right) \]
\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right)
\log 2 - \mathsf{fma}\left(x \cdot x, 0.25, \log x\right)
(FPCore (x)
 :precision binary64
 (log (+ (/ 1.0 x) (/ (sqrt (- 1.0 (* x x))) x))))
(FPCore (x) :precision binary64 (- (log 2.0) (fma (* x x) 0.25 (log x))))
double code(double x) {
	return log((1.0 / x) + (sqrt(1.0 - (x * x)) / x));
}
double code(double x) {
	return log(2.0) - fma((x * x), 0.25, log(x));
}

Error

Bits error versus x

Derivation

  1. Initial program 0.0

    \[\log \left(\frac{1}{x} + \frac{\sqrt{1 - x \cdot x}}{x}\right) \]
  2. Taylor expanded around 0 0.5

    \[\leadsto \color{blue}{\log 2 - \left(\log x + 0.25 \cdot {x}^{2}\right)} \]
  3. Simplified0.5

    \[\leadsto \color{blue}{\log 2 - \mathsf{fma}\left(0.25, x \cdot x, \log x\right)} \]
  4. Using strategy rm
  5. Applied flip3--_binary640.8

    \[\leadsto \color{blue}{\frac{{\log 2}^{3} - {\left(\mathsf{fma}\left(0.25, x \cdot x, \log x\right)\right)}^{3}}{\log 2 \cdot \log 2 + \left(\mathsf{fma}\left(0.25, x \cdot x, \log x\right) \cdot \mathsf{fma}\left(0.25, x \cdot x, \log x\right) + \log 2 \cdot \mathsf{fma}\left(0.25, x \cdot x, \log x\right)\right)}} \]
  6. Simplified0.8

    \[\leadsto \frac{{\log 2}^{3} - {\left(\mathsf{fma}\left(0.25, x \cdot x, \log x\right)\right)}^{3}}{\color{blue}{\mathsf{fma}\left(\log 2, \log 2, \mathsf{fma}\left(0.25, x \cdot x, \log x\right) \cdot \left(\log 2 + \mathsf{fma}\left(0.25, x \cdot x, \log x\right)\right)\right)}} \]
  7. Taylor expanded around inf 0.5

    \[\leadsto \color{blue}{\left(\log \left(\frac{1}{x}\right) + \log 2\right) - 0.25 \cdot {x}^{2}} \]
  8. Simplified0.5

    \[\leadsto \color{blue}{\log 2 - \mathsf{fma}\left(x \cdot x, 0.25, \log x\right)} \]
  9. Final simplification0.5

    \[\leadsto \log 2 - \mathsf{fma}\left(x \cdot x, 0.25, \log x\right) \]

Reproduce

herbie shell --seed 2021211 
(FPCore (x)
  :name "Hyperbolic arc-(co)secant"
  :precision binary64
  (log (+ (/ 1.0 x) (/ (sqrt (- 1.0 (* x x))) x))))