| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 13632 |
\[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot \mathsf{fma}\left(x, x, x\right)}{1 - x \cdot x}\right)
\]

(FPCore (x) :precision binary64 (* 0.5 (log1p (/ (* 2.0 x) (- 1.0 x)))))
(FPCore (x) :precision binary64 (* 0.5 (log1p (/ (* 2.0 (fma x x x)) (- 1.0 (* x x))))))
double code(double x) {
return 0.5 * log1p(((2.0 * x) / (1.0 - x)));
}
double code(double x) {
return 0.5 * log1p(((2.0 * fma(x, x, x)) / (1.0 - (x * x))));
}
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(Float64(2.0 * fma(x, x, x)) / Float64(1.0 - Float64(x * x))))) 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[(N[(2.0 * N[(x * x + x), $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right)
0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot \mathsf{fma}\left(x, x, x\right)}{1 - x \cdot x}\right)
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Initial program 100.0%
Simplified99.8%
[Start]100.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right)
\] |
|---|---|
associate-/l* [=>]99.8% | \[ 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{2}{\frac{1 - x}{x}}}\right)
\] |
Applied egg-rr100.0%
[Start]99.8% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{2}{\frac{1 - x}{x}}\right)
\] |
|---|---|
associate-/l* [<=]100.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{2 \cdot x}{1 - x}}\right)
\] |
flip-- [=>]100.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{\color{blue}{\frac{1 \cdot 1 - x \cdot x}{1 + x}}}\right)
\] |
associate-/r/ [=>]100.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{2 \cdot x}{1 \cdot 1 - x \cdot x} \cdot \left(1 + x\right)}\right)
\] |
add-log-exp [=>]8.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{\color{blue}{\log \left(e^{2 \cdot x}\right)}}{1 \cdot 1 - x \cdot x} \cdot \left(1 + x\right)\right)
\] |
*-commutative [=>]8.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{\log \left(e^{\color{blue}{x \cdot 2}}\right)}{1 \cdot 1 - x \cdot x} \cdot \left(1 + x\right)\right)
\] |
exp-lft-sqr [=>]7.9% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{\log \color{blue}{\left(e^{x} \cdot e^{x}\right)}}{1 \cdot 1 - x \cdot x} \cdot \left(1 + x\right)\right)
\] |
log-prod [=>]7.9% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{\color{blue}{\log \left(e^{x}\right) + \log \left(e^{x}\right)}}{1 \cdot 1 - x \cdot x} \cdot \left(1 + x\right)\right)
\] |
add-log-exp [<=]20.6% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{\color{blue}{x} + \log \left(e^{x}\right)}{1 \cdot 1 - x \cdot x} \cdot \left(1 + x\right)\right)
\] |
add-log-exp [<=]100.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{x + \color{blue}{x}}{1 \cdot 1 - x \cdot x} \cdot \left(1 + x\right)\right)
\] |
metadata-eval [=>]100.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{x + x}{\color{blue}{1} - x \cdot x} \cdot \left(1 + x\right)\right)
\] |
Simplified100.0%
[Start]100.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{x + x}{1 - x \cdot x} \cdot \left(1 + x\right)\right)
\] |
|---|---|
associate-*l/ [=>]100.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{\left(x + x\right) \cdot \left(1 + x\right)}{1 - x \cdot x}}\right)
\] |
count-2 [=>]100.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{\color{blue}{\left(2 \cdot x\right)} \cdot \left(1 + x\right)}{1 - x \cdot x}\right)
\] |
associate-*l* [=>]100.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{\color{blue}{2 \cdot \left(x \cdot \left(1 + x\right)\right)}}{1 - x \cdot x}\right)
\] |
+-commutative [=>]100.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot \left(x \cdot \color{blue}{\left(x + 1\right)}\right)}{1 - x \cdot x}\right)
\] |
distribute-rgt-in [=>]100.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot \color{blue}{\left(x \cdot x + 1 \cdot x\right)}}{1 - x \cdot x}\right)
\] |
unpow2 [<=]100.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot \left(\color{blue}{{x}^{2}} + 1 \cdot x\right)}{1 - x \cdot x}\right)
\] |
*-lft-identity [=>]100.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot \left({x}^{2} + \color{blue}{x}\right)}{1 - x \cdot x}\right)
\] |
unpow2 [=>]100.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot \left(\color{blue}{x \cdot x} + x\right)}{1 - x \cdot x}\right)
\] |
fma-def [=>]100.0% | \[ 0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot \color{blue}{\mathsf{fma}\left(x, x, x\right)}}{1 - x \cdot x}\right)
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 13632 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 6976 |
| Alternative 3 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 6976 |
| Alternative 4 | |
|---|---|
| Accuracy | 97.7% |
| Cost | 6720 |
| Alternative 5 | |
|---|---|
| Accuracy | 0.0% |
| Cost | 6592 |
herbie shell --seed 2023263
(FPCore (x)
:name "Rust f64::atanh"
:precision binary64
(* 0.5 (log1p (/ (* 2.0 x) (- 1.0 x)))))