| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 6784 |
\[-\log \left(\frac{1}{x} + -1\right)
\]
(FPCore (x) :precision binary64 (- (log (- (/ 1.0 x) 1.0))))
(FPCore (x) :precision binary64 (- (log1p (+ (/ 1.0 x) -2.0))))
double code(double x) {
return -log(((1.0 / x) - 1.0));
}
double code(double x) {
return -log1p(((1.0 / x) + -2.0));
}
public static double code(double x) {
return -Math.log(((1.0 / x) - 1.0));
}
public static double code(double x) {
return -Math.log1p(((1.0 / x) + -2.0));
}
def code(x): return -math.log(((1.0 / x) - 1.0))
def code(x): return -math.log1p(((1.0 / x) + -2.0))
function code(x) return Float64(-log(Float64(Float64(1.0 / x) - 1.0))) end
function code(x) return Float64(-log1p(Float64(Float64(1.0 / x) + -2.0))) end
code[x_] := (-N[Log[N[(N[(1.0 / x), $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision])
code[x_] := (-N[Log[1 + N[(N[(1.0 / x), $MachinePrecision] + -2.0), $MachinePrecision]], $MachinePrecision])
-\log \left(\frac{1}{x} - 1\right)
-\mathsf{log1p}\left(\frac{1}{x} + -2\right)
Results
Initial program 99.9%
Applied egg-rr99.9%
[Start]99.9 | \[ -\log \left(\frac{1}{x} - 1\right)
\] |
|---|---|
log1p-expm1-u [=>]99.9 | \[ -\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(\frac{1}{x} - 1\right)\right)\right)}
\] |
expm1-udef [=>]99.9 | \[ -\mathsf{log1p}\left(\color{blue}{e^{\log \left(\frac{1}{x} - 1\right)} - 1}\right)
\] |
add-exp-log [<=]99.9 | \[ -\mathsf{log1p}\left(\color{blue}{\left(\frac{1}{x} - 1\right)} - 1\right)
\] |
add-exp-log [=>]99.9 | \[ -\mathsf{log1p}\left(\left(\color{blue}{e^{\log \left(\frac{1}{x}\right)}} - 1\right) - 1\right)
\] |
expm1-def [=>]99.9 | \[ -\mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(\log \left(\frac{1}{x}\right)\right)} - 1\right)
\] |
log-rec [=>]99.9 | \[ -\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{-\log x}\right) - 1\right)
\] |
Taylor expanded in x around 0 99.9%
Simplified99.9%
[Start]99.9 | \[ -\mathsf{log1p}\left(e^{-\log x} - 2\right)
\] |
|---|---|
sub-neg [=>]99.9 | \[ -\mathsf{log1p}\left(\color{blue}{e^{-\log x} + \left(-2\right)}\right)
\] |
exp-neg [=>]99.9 | \[ -\mathsf{log1p}\left(\color{blue}{\frac{1}{e^{\log x}}} + \left(-2\right)\right)
\] |
rem-exp-log [=>]99.9 | \[ -\mathsf{log1p}\left(\frac{1}{\color{blue}{x}} + \left(-2\right)\right)
\] |
metadata-eval [=>]99.9 | \[ -\mathsf{log1p}\left(\frac{1}{x} + \color{blue}{-2}\right)
\] |
Final simplification99.9%
| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 6784 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 6592 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.3% |
| Cost | 6464 |
| Alternative 4 | |
|---|---|
| Accuracy | 2.3% |
| Cost | 64 |
herbie shell --seed 2023133
(FPCore (x)
:name "neg log"
:precision binary64
(- (log (- (/ 1.0 x) 1.0))))