Average Error: 0.0 → 0.0
Time: 2.6s
Precision: binary64
Cost: 13632
\[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \]
\[0.5 \cdot \mathsf{log1p}\left(x \cdot \left(\frac{-2}{\mathsf{fma}\left(x, x, -1\right)} \cdot \left(x + 1\right)\right)\right) \]
(FPCore (x) :precision binary64 (* 0.5 (log1p (/ (* 2.0 x) (- 1.0 x)))))
(FPCore (x)
 :precision binary64
 (* 0.5 (log1p (* x (* (/ -2.0 (fma x x -1.0)) (+ x 1.0))))))
double code(double x) {
	return 0.5 * log1p(((2.0 * x) / (1.0 - x)));
}
double code(double x) {
	return 0.5 * log1p((x * ((-2.0 / fma(x, x, -1.0)) * (x + 1.0))));
}
function code(x)
	return Float64(0.5 * log1p(Float64(Float64(2.0 * x) / Float64(1.0 - x))))
end
function code(x)
	return Float64(0.5 * log1p(Float64(x * Float64(Float64(-2.0 / fma(x, x, -1.0)) * Float64(x + 1.0)))))
end
code[x_] := N[(0.5 * N[Log[1 + N[(N[(2.0 * x), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(0.5 * N[Log[1 + N[(x * N[(N[(-2.0 / N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right)
0.5 \cdot \mathsf{log1p}\left(x \cdot \left(\frac{-2}{\mathsf{fma}\left(x, x, -1\right)} \cdot \left(x + 1\right)\right)\right)

Error

Derivation

  1. Initial program 0.0

    \[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \]
  2. Simplified0.0

    \[\leadsto \color{blue}{0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{x + -1}\right)} \]
    Proof
    (*.f64 1/2 (log1p.f64 (*.f64 x (/.f64 -2 (+.f64 x -1))))): 0 points increase in error, 0 points decrease in error
    (*.f64 1/2 (log1p.f64 (*.f64 x (/.f64 (Rewrite<= metadata-eval (/.f64 2 -1)) (+.f64 x -1))))): 0 points increase in error, 0 points decrease in error
    (*.f64 1/2 (log1p.f64 (*.f64 x (/.f64 (/.f64 2 -1) (+.f64 x (Rewrite<= metadata-eval (neg.f64 1))))))): 0 points increase in error, 0 points decrease in error
    (*.f64 1/2 (log1p.f64 (*.f64 x (/.f64 (/.f64 2 -1) (Rewrite<= sub-neg_binary64 (-.f64 x 1)))))): 0 points increase in error, 0 points decrease in error
    (*.f64 1/2 (log1p.f64 (*.f64 x (Rewrite<= associate-/r*_binary64 (/.f64 2 (*.f64 -1 (-.f64 x 1))))))): 0 points increase in error, 0 points decrease in error
    (*.f64 1/2 (log1p.f64 (*.f64 x (/.f64 2 (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 x 1))))))): 0 points increase in error, 0 points decrease in error
    (*.f64 1/2 (log1p.f64 (*.f64 x (/.f64 2 (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 x 1))))))): 0 points increase in error, 0 points decrease in error
    (*.f64 1/2 (log1p.f64 (*.f64 x (/.f64 2 (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 x) 1)))))): 0 points increase in error, 0 points decrease in error
    (*.f64 1/2 (log1p.f64 (*.f64 x (/.f64 2 (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 x)) 1))))): 0 points increase in error, 0 points decrease in error
    (*.f64 1/2 (log1p.f64 (*.f64 x (/.f64 2 (Rewrite<= +-commutative_binary64 (+.f64 1 (neg.f64 x))))))): 0 points increase in error, 0 points decrease in error
    (*.f64 1/2 (log1p.f64 (*.f64 x (/.f64 2 (Rewrite<= sub-neg_binary64 (-.f64 1 x)))))): 0 points increase in error, 0 points decrease in error
    (*.f64 1/2 (log1p.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 x 2) (-.f64 1 x))))): 1 points increase in error, 2 points decrease in error
    (*.f64 1/2 (log1p.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 2 x)) (-.f64 1 x)))): 0 points increase in error, 0 points decrease in error
  3. Applied egg-rr0.0

    \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\left(\frac{-2}{\mathsf{fma}\left(x, x, -1\right)} \cdot \left(x + 1\right)\right)}\right) \]
  4. Final simplification0.0

    \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \left(\frac{-2}{\mathsf{fma}\left(x, x, -1\right)} \cdot \left(x + 1\right)\right)\right) \]

Alternatives

Alternative 1
Error0.0
Cost6976
\[0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{x + -1}\right) \]
Alternative 2
Error0.0
Cost6976
\[0.5 \cdot \mathsf{log1p}\left(\frac{x \cdot 2}{1 - x}\right) \]
Alternative 3
Error0.7
Cost320
\[0.5 \cdot \left(x \cdot 2\right) \]

Error

Reproduce

herbie shell --seed 2022332 
(FPCore (x)
  :name "Rust f64::atanh"
  :precision binary64
  (* 0.5 (log1p (/ (* 2.0 x) (- 1.0 x)))))