Average Error: 0.0 → 0.0
Time: 1.5s
Precision: binary64
\[-\log \left(\frac{1}{x} - 1\right) \]
\[\begin{array}{l} t_0 := \sqrt{\frac{1}{x}}\\ -\log \left(\mathsf{fma}\left(t_0, t_0, -1\right) + \mathsf{fma}\left(-1, 1, 1\right)\right) \end{array} \]
-\log \left(\frac{1}{x} - 1\right)
\begin{array}{l}
t_0 := \sqrt{\frac{1}{x}}\\
-\log \left(\mathsf{fma}\left(t_0, t_0, -1\right) + \mathsf{fma}\left(-1, 1, 1\right)\right)
\end{array}
(FPCore (x) :precision binary64 (- (log (- (/ 1.0 x) 1.0))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sqrt (/ 1.0 x))))
   (- (log (+ (fma t_0 t_0 -1.0) (fma -1.0 1.0 1.0))))))
double code(double x) {
	return -log((1.0 / x) - 1.0);
}
double code(double x) {
	double t_0 = sqrt(1.0 / x);
	return -log(fma(t_0, t_0, -1.0) + fma(-1.0, 1.0, 1.0));
}

Error

Bits error versus x

Derivation

  1. Initial program 0.0

    \[-\log \left(\frac{1}{x} - 1\right) \]
  2. Applied *-un-lft-identity_binary640.0

    \[\leadsto -\log \left(\frac{1}{x} - \color{blue}{1 \cdot 1}\right) \]
  3. Applied add-sqr-sqrt_binary640.0

    \[\leadsto -\log \left(\color{blue}{\sqrt{\frac{1}{x}} \cdot \sqrt{\frac{1}{x}}} - 1 \cdot 1\right) \]
  4. Applied prod-diff_binary640.0

    \[\leadsto -\log \color{blue}{\left(\mathsf{fma}\left(\sqrt{\frac{1}{x}}, \sqrt{\frac{1}{x}}, -1 \cdot 1\right) + \mathsf{fma}\left(-1, 1, 1 \cdot 1\right)\right)} \]
  5. Final simplification0.0

    \[\leadsto -\log \left(\mathsf{fma}\left(\sqrt{\frac{1}{x}}, \sqrt{\frac{1}{x}}, -1\right) + \mathsf{fma}\left(-1, 1, 1\right)\right) \]

Reproduce

herbie shell --seed 2022077 
(FPCore (x)
  :name "neg log"
  :precision binary64
  (- (log (- (/ 1.0 x) 1.0))))