Rust f32::atanh

?

Percentage Accurate: 99.8% → 99.7%
Time: 8.3s
Precision: binary32
Cost: 3488

?

\[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \]
\[0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{1 - x}\right) \]
(FPCore (x) :precision binary32 (* 0.5 (log1p (/ (* 2.0 x) (- 1.0 x)))))
(FPCore (x) :precision binary32 (* 0.5 (log1p (* x (/ 2.0 (- 1.0 x))))))
float code(float x) {
	return 0.5f * log1pf(((2.0f * x) / (1.0f - x)));
}
float code(float x) {
	return 0.5f * log1pf((x * (2.0f / (1.0f - x))));
}
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) * log1p(Float32(x * Float32(Float32(2.0) / Float32(Float32(1.0) - x)))))
end
0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right)
0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{1 - x}\right)

Local Percentage Accuracy?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

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.2%

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

    [Start]99.8

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

    associate-/l* [=>]99.2

    \[ 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{2}{\frac{1 - x}{x}}}\right) \]
  3. Applied egg-rr99.8%

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

    [Start]99.2

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

    associate-/r/ [=>]99.8

    \[ 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{2}{1 - x} \cdot x}\right) \]
  4. Final simplification99.8%

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

Alternatives

Alternative 1
Accuracy98.7%
Cost416
\[0.5 \cdot \left(x \cdot \left(x \cdot \left(x \cdot 0.6666666666666666\right)\right) + 2 \cdot x\right) \]
Alternative 2
Accuracy97.1%
Cost160
\[0.5 \cdot \left(2 \cdot x\right) \]

Error

Reproduce?

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