Average Error: 0.0 → 0.0
Time: 3.4s
Precision: 64
\[\frac{-\left(f + n\right)}{f - n}\]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{-\left(f + n\right)}{f - n}\right)\right)\]
\frac{-\left(f + n\right)}{f - n}
\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{-\left(f + n\right)}{f - n}\right)\right)
double code(double f, double n) {
	return (-(f + n) / (f - n));
}
double code(double f, double n) {
	return log1p(expm1((-(f + n) / (f - n))));
}

Error

Bits error versus f

Bits error versus n

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.0

    \[\frac{-\left(f + n\right)}{f - n}\]
  2. Using strategy rm
  3. Applied log1p-expm1-u0.0

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{-\left(f + n\right)}{f - n}\right)\right)}\]
  4. Final simplification0.0

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{-\left(f + n\right)}{f - n}\right)\right)\]

Reproduce

herbie shell --seed 2020057 +o rules:numerics
(FPCore (f n)
  :name "subtraction fraction"
  :precision binary64
  (/ (- (+ f n)) (- f n)))