| Alternative 1 | |
|---|---|
| Error | 0.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) (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 * ((log1p(x) + 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 * ((Math.log1p(x) + 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 * ((math.log1p(x) + 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(log1p(x) + log1p(x)) - log1p(Float64(x * Float64(-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[(N[Log[1 + x], $MachinePrecision] + 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(\left(\mathsf{log1p}\left(x\right) + \mathsf{log1p}\left(x\right)\right) - \mathsf{log1p}\left(x \cdot \left(-x\right)\right)\right)
Results
Initial program 58.7
Simplified58.7
[Start]58.7 | \[ \frac{1}{2} \cdot \log \left(\frac{1 + x}{1 - x}\right)
\] |
|---|---|
metadata-eval [=>]58.7 | \[ \color{blue}{0.5} \cdot \log \left(\frac{1 + x}{1 - x}\right)
\] |
Applied egg-rr0.5
Simplified0.0
[Start]0.5 | \[ 0.5 \cdot \left(\left(\mathsf{log1p}\left(x\right) - \log \left(1 - x \cdot x\right)\right) + \mathsf{log1p}\left(x\right)\right)
\] |
|---|---|
+-commutative [=>]0.5 | \[ 0.5 \cdot \color{blue}{\left(\mathsf{log1p}\left(x\right) + \left(\mathsf{log1p}\left(x\right) - \log \left(1 - x \cdot x\right)\right)\right)}
\] |
associate-+r- [=>]0.5 | \[ 0.5 \cdot \color{blue}{\left(\left(\mathsf{log1p}\left(x\right) + \mathsf{log1p}\left(x\right)\right) - \log \left(1 - x \cdot x\right)\right)}
\] |
cancel-sign-sub-inv [=>]0.5 | \[ 0.5 \cdot \left(\left(\mathsf{log1p}\left(x\right) + \mathsf{log1p}\left(x\right)\right) - \log \color{blue}{\left(1 + \left(-x\right) \cdot x\right)}\right)
\] |
*-commutative [<=]0.5 | \[ 0.5 \cdot \left(\left(\mathsf{log1p}\left(x\right) + \mathsf{log1p}\left(x\right)\right) - \log \left(1 + \color{blue}{x \cdot \left(-x\right)}\right)\right)
\] |
log1p-def [=>]0.0 | \[ 0.5 \cdot \left(\left(\mathsf{log1p}\left(x\right) + \mathsf{log1p}\left(x\right)\right) - \color{blue}{\mathsf{log1p}\left(x \cdot \left(-x\right)\right)}\right)
\] |
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 13184 |
| Alternative 2 | |
|---|---|
| Error | 0.3 |
| Cost | 7040 |
| Alternative 3 | |
|---|---|
| Error | 0.6 |
| Cost | 320 |
| Alternative 4 | |
|---|---|
| Error | 60.6 |
| Cost | 64 |
herbie shell --seed 2023066
(FPCore (x)
:name "Hyperbolic arc-(co)tangent"
:precision binary64
(* (/ 1.0 2.0) (log (/ (+ 1.0 x) (- 1.0 x)))))