?

Average Accuracy: 99.8% → 99.2%
Time: 6.3s
Precision: binary32
Cost: 10240

?

\[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \]
\[0.5 \cdot \left(0.2857142857142857 \cdot {x}^{7} + \left(x \cdot 2 + \left(0.6666666666666666 \cdot {x}^{3} + 0.4 \cdot {x}^{5}\right)\right)\right) \]
(FPCore (x) :precision binary32 (* 0.5 (log1p (/ (* 2.0 x) (- 1.0 x)))))
(FPCore (x)
 :precision binary32
 (*
  0.5
  (+
   (* 0.2857142857142857 (pow x 7.0))
   (+ (* x 2.0) (+ (* 0.6666666666666666 (pow x 3.0)) (* 0.4 (pow x 5.0)))))))
float code(float x) {
	return 0.5f * log1pf(((2.0f * x) / (1.0f - x)));
}
float code(float x) {
	return 0.5f * ((0.2857142857142857f * powf(x, 7.0f)) + ((x * 2.0f) + ((0.6666666666666666f * powf(x, 3.0f)) + (0.4f * powf(x, 5.0f)))));
}
function code(x)
	return Float32(Float32(0.5) * log1p(Float32(Float32(Float32(2.0) * x) / Float32(Float32(1.0) - x))))
end
function code(x)
	return Float32(Float32(0.5) * Float32(Float32(Float32(0.2857142857142857) * (x ^ Float32(7.0))) + Float32(Float32(x * Float32(2.0)) + Float32(Float32(Float32(0.6666666666666666) * (x ^ Float32(3.0))) + Float32(Float32(0.4) * (x ^ Float32(5.0)))))))
end
0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right)
0.5 \cdot \left(0.2857142857142857 \cdot {x}^{7} + \left(x \cdot 2 + \left(0.6666666666666666 \cdot {x}^{3} + 0.4 \cdot {x}^{5}\right)\right)\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 99.8%

    \[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \]
  2. Simplified99.7%

    \[\leadsto \color{blue}{0.5 \cdot \mathsf{log1p}\left(\frac{2}{1 - x} \cdot x\right)} \]
    Proof

    [Start]99.8

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

    associate-*l/ [<=]99.7

    \[ 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{2}{1 - x} \cdot x}\right) \]
  3. Taylor expanded in x around 0 99.2%

    \[\leadsto 0.5 \cdot \color{blue}{\left(0.2857142857142857 \cdot {x}^{7} + \left(2 \cdot x + \left(0.6666666666666666 \cdot {x}^{3} + 0.4 \cdot {x}^{5}\right)\right)\right)} \]
  4. Final simplification99.2%

    \[\leadsto 0.5 \cdot \left(0.2857142857142857 \cdot {x}^{7} + \left(x \cdot 2 + \left(0.6666666666666666 \cdot {x}^{3} + 0.4 \cdot {x}^{5}\right)\right)\right) \]

Alternatives

Alternative 1
Accuracy99.7%
Cost3488
\[0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{1 - x}\right) \]
Alternative 2
Accuracy99.8%
Cost3488
\[0.5 \cdot \mathsf{log1p}\left(\frac{x \cdot 2}{1 - x}\right) \]
Alternative 3
Accuracy96.8%
Cost160
\[0.5 \cdot \left(x \cdot 2\right) \]

Error

Reproduce?

herbie shell --seed 2023135 
(FPCore (x)
  :name "Rust f32::atanh"
  :precision binary32
  (* 0.5 (log1p (/ (* 2.0 x) (- 1.0 x)))))