| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 13184 |
\[0.5 \cdot \left(\mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x\right)\right)
\]
(FPCore (x) :precision binary64 (* (/ 1.0 2.0) (log (/ (+ 1.0 x) (- 1.0 x)))))
(FPCore (x) :precision binary64 (* 0.5 (- (* 2.0 (log1p x)) (log1p (- (* x x))))))
double code(double x) {
return (1.0 / 2.0) * log(((1.0 + x) / (1.0 - x)));
}
double code(double x) {
return 0.5 * ((2.0 * log1p(x)) - log1p(-(x * x)));
}
public static double code(double x) {
return (1.0 / 2.0) * Math.log(((1.0 + x) / (1.0 - x)));
}
public static double code(double x) {
return 0.5 * ((2.0 * Math.log1p(x)) - Math.log1p(-(x * x)));
}
def code(x): return (1.0 / 2.0) * math.log(((1.0 + x) / (1.0 - x)))
def code(x): return 0.5 * ((2.0 * math.log1p(x)) - math.log1p(-(x * x)))
function code(x) return Float64(Float64(1.0 / 2.0) * log(Float64(Float64(1.0 + x) / Float64(1.0 - x)))) end
function code(x) return Float64(0.5 * Float64(Float64(2.0 * log1p(x)) - log1p(Float64(-Float64(x * x))))) end
code[x_] := N[(N[(1.0 / 2.0), $MachinePrecision] * N[Log[N[(N[(1.0 + x), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(0.5 * N[(N[(2.0 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision] - N[Log[1 + (-N[(x * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right)
0.5 \cdot \left(2 \cdot \mathsf{log1p}\left(x\right) - \mathsf{log1p}\left(-x \cdot x\right)\right)
Results
Initial program 7.3%
Simplified7.3%
[Start]7.3 | \[ \frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right)
\] |
|---|---|
metadata-eval [=>]7.3 | \[ \color{blue}{0.5} \cdot \log \left(\frac{1 + x}{1 - x}\right)
\] |
Applied egg-rr7.3%
[Start]7.3 | \[ 0.5 \cdot \log \left(\frac{1 + x}{1 - x}\right)
\] |
|---|---|
clear-num [=>]7.3 | \[ 0.5 \cdot \log \color{blue}{\left(\frac{1}{\frac{1 - x}{1 + x}}\right)}
\] |
clear-num [=>]7.3 | \[ 0.5 \cdot \log \color{blue}{\left(\frac{1}{\frac{\frac{1 - x}{1 + x}}{1}}\right)}
\] |
log-rec [=>]7.3 | \[ 0.5 \cdot \color{blue}{\left(-\log \left(\frac{\frac{1 - x}{1 + x}}{1}\right)\right)}
\] |
Applied egg-rr100.0%
[Start]7.3 | \[ 0.5 \cdot \left(-\log \left(\frac{\frac{1 - x}{1 + x}}{1}\right)\right)
\] |
|---|---|
/-rgt-identity [=>]7.3 | \[ 0.5 \cdot \left(-\log \color{blue}{\left(\frac{1 - x}{1 + x}\right)}\right)
\] |
flip-- [=>]7.3 | \[ 0.5 \cdot \left(-\log \left(\frac{\color{blue}{\frac{1 \cdot 1 - x \cdot x}{1 + x}}}{1 + x}\right)\right)
\] |
associate-/l/ [=>]7.3 | \[ 0.5 \cdot \left(-\log \color{blue}{\left(\frac{1 \cdot 1 - x \cdot x}{\left(1 + x\right) \cdot \left(1 + x\right)}\right)}\right)
\] |
log-div [=>]7.3 | \[ 0.5 \cdot \left(-\color{blue}{\left(\log \left(1 \cdot 1 - x \cdot x\right) - \log \left(\left(1 + x\right) \cdot \left(1 + x\right)\right)\right)}\right)
\] |
metadata-eval [=>]7.3 | \[ 0.5 \cdot \left(-\left(\log \left(\color{blue}{1} - x \cdot x\right) - \log \left(\left(1 + x\right) \cdot \left(1 + x\right)\right)\right)\right)
\] |
sub-neg [=>]7.3 | \[ 0.5 \cdot \left(-\left(\log \color{blue}{\left(1 + \left(-x \cdot x\right)\right)} - \log \left(\left(1 + x\right) \cdot \left(1 + x\right)\right)\right)\right)
\] |
log1p-def [=>]7.6 | \[ 0.5 \cdot \left(-\left(\color{blue}{\mathsf{log1p}\left(-x \cdot x\right)} - \log \left(\left(1 + x\right) \cdot \left(1 + x\right)\right)\right)\right)
\] |
pow2 [=>]7.6 | \[ 0.5 \cdot \left(-\left(\mathsf{log1p}\left(-x \cdot x\right) - \log \color{blue}{\left({\left(1 + x\right)}^{2}\right)}\right)\right)
\] |
metadata-eval [<=]7.6 | \[ 0.5 \cdot \left(-\left(\mathsf{log1p}\left(-x \cdot x\right) - \log \left({\left(1 + x\right)}^{\color{blue}{\left(1 + 1\right)}}\right)\right)\right)
\] |
log-pow [=>]7.6 | \[ 0.5 \cdot \left(-\left(\mathsf{log1p}\left(-x \cdot x\right) - \color{blue}{\left(1 + 1\right) \cdot \log \left(1 + x\right)}\right)\right)
\] |
metadata-eval [=>]7.6 | \[ 0.5 \cdot \left(-\left(\mathsf{log1p}\left(-x \cdot x\right) - \color{blue}{2} \cdot \log \left(1 + x\right)\right)\right)
\] |
log1p-udef [<=]100.0 | \[ 0.5 \cdot \left(-\left(\mathsf{log1p}\left(-x \cdot x\right) - 2 \cdot \color{blue}{\mathsf{log1p}\left(x\right)}\right)\right)
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 13184 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 7040 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.9% |
| Cost | 320 |
herbie shell --seed 2023160
(FPCore (x)
:name "Hyperbolic arc-(co)tangent"
:precision binary64
(* (/ 1.0 2.0) (log (/ (+ 1.0 x) (- 1.0 x)))))