| 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 (+ (log1p (* x (- x))) (* (log1p (- x)) -2.0))))
double code(double x) {
return (1.0 / 2.0) * log(((1.0 + x) / (1.0 - x)));
}
double code(double x) {
return 0.5 * (log1p((x * -x)) + (log1p(-x) * -2.0));
}
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 * (Math.log1p((x * -x)) + (Math.log1p(-x) * -2.0));
}
def code(x): return (1.0 / 2.0) * math.log(((1.0 + x) / (1.0 - x)))
def code(x): return 0.5 * (math.log1p((x * -x)) + (math.log1p(-x) * -2.0))
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(log1p(Float64(x * Float64(-x))) + Float64(log1p(Float64(-x)) * -2.0))) 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[Log[1 + N[(x * (-x)), $MachinePrecision]], $MachinePrecision] + N[(N[Log[1 + (-x)], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right)
0.5 \cdot \left(\mathsf{log1p}\left(x \cdot \left(-x\right)\right) + \mathsf{log1p}\left(-x\right) \cdot -2\right)
Results
Initial program 8.6%
Simplified8.6%
[Start]8.6 | \[ \frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right)
\] |
|---|---|
metadata-eval [=>]8.6 | \[ \color{blue}{0.5} \cdot \log \left(\frac{1 + x}{1 - x}\right)
\] |
Applied egg-rr99.1%
Simplified100.0%
[Start]99.1 | \[ 0.5 \cdot \left(\log \left(1 - x \cdot x\right) - \left(\mathsf{log1p}\left(-x\right) + \mathsf{log1p}\left(-x\right)\right)\right)
\] |
|---|---|
cancel-sign-sub-inv [=>]99.1 | \[ 0.5 \cdot \left(\log \color{blue}{\left(1 + \left(-x\right) \cdot x\right)} - \left(\mathsf{log1p}\left(-x\right) + \mathsf{log1p}\left(-x\right)\right)\right)
\] |
*-commutative [<=]99.1 | \[ 0.5 \cdot \left(\log \left(1 + \color{blue}{x \cdot \left(-x\right)}\right) - \left(\mathsf{log1p}\left(-x\right) + \mathsf{log1p}\left(-x\right)\right)\right)
\] |
log1p-def [=>]100.0 | \[ 0.5 \cdot \left(\color{blue}{\mathsf{log1p}\left(x \cdot \left(-x\right)\right)} - \left(\mathsf{log1p}\left(-x\right) + \mathsf{log1p}\left(-x\right)\right)\right)
\] |
count-2 [=>]100.0 | \[ 0.5 \cdot \left(\mathsf{log1p}\left(x \cdot \left(-x\right)\right) - \color{blue}{2 \cdot \mathsf{log1p}\left(-x\right)}\right)
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 13184 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 832 |
| Alternative 3 | |
|---|---|
| Accuracy | 99.0% |
| Cost | 320 |
herbie shell --seed 2023129
(FPCore (x)
:name "Hyperbolic arc-(co)tangent"
:precision binary64
(* (/ 1.0 2.0) (log (/ (+ 1.0 x) (- 1.0 x)))))