
(FPCore (x) :precision binary64 (- (log (- (/ 1.0 x) 1.0))))
double code(double x) {
return -log(((1.0 / x) - 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = -log(((1.0d0 / x) - 1.0d0))
end function
public static double code(double x) {
return -Math.log(((1.0 / x) - 1.0));
}
def code(x): return -math.log(((1.0 / x) - 1.0))
function code(x) return Float64(-log(Float64(Float64(1.0 / x) - 1.0))) end
function tmp = code(x) tmp = -log(((1.0 / x) - 1.0)); end
code[x_] := (-N[Log[N[(N[(1.0 / x), $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}
\\
-\log \left(\frac{1}{x} - 1\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (log (- (/ 1.0 x) 1.0))))
double code(double x) {
return -log(((1.0 / x) - 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = -log(((1.0d0 / x) - 1.0d0))
end function
public static double code(double x) {
return -Math.log(((1.0 / x) - 1.0));
}
def code(x): return -math.log(((1.0 / x) - 1.0))
function code(x) return Float64(-log(Float64(Float64(1.0 / x) - 1.0))) end
function tmp = code(x) tmp = -log(((1.0 / x) - 1.0)); end
code[x_] := (-N[Log[N[(N[(1.0 / x), $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}
\\
-\log \left(\frac{1}{x} - 1\right)
\end{array}
(FPCore (x) :precision binary64 (+ 1.0 (- -1.0 (log (+ (/ 1.0 x) -1.0)))))
double code(double x) {
return 1.0 + (-1.0 - log(((1.0 / x) + -1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + ((-1.0d0) - log(((1.0d0 / x) + (-1.0d0))))
end function
public static double code(double x) {
return 1.0 + (-1.0 - Math.log(((1.0 / x) + -1.0)));
}
def code(x): return 1.0 + (-1.0 - math.log(((1.0 / x) + -1.0)))
function code(x) return Float64(1.0 + Float64(-1.0 - log(Float64(Float64(1.0 / x) + -1.0)))) end
function tmp = code(x) tmp = 1.0 + (-1.0 - log(((1.0 / x) + -1.0))); end
code[x_] := N[(1.0 + N[(-1.0 - N[Log[N[(N[(1.0 / x), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(-1 - \log \left(\frac{1}{x} + -1\right)\right)
\end{array}
Initial program 99.9%
expm1-log1p-u98.2%
expm1-udef98.2%
log1p-udef98.2%
rem-exp-log99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (- (log (+ (/ 1.0 x) -1.0))))
double code(double x) {
return -log(((1.0 / x) + -1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = -log(((1.0d0 / x) + (-1.0d0)))
end function
public static double code(double x) {
return -Math.log(((1.0 / x) + -1.0));
}
def code(x): return -math.log(((1.0 / x) + -1.0))
function code(x) return Float64(-log(Float64(Float64(1.0 / x) + -1.0))) end
function tmp = code(x) tmp = -log(((1.0 / x) + -1.0)); end
code[x_] := (-N[Log[N[(N[(1.0 / x), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}
\\
-\log \left(\frac{1}{x} + -1\right)
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (+ x (log x)))
double code(double x) {
return x + log(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x + log(x)
end function
public static double code(double x) {
return x + Math.log(x);
}
def code(x): return x + math.log(x)
function code(x) return Float64(x + log(x)) end
function tmp = code(x) tmp = x + log(x); end
code[x_] := N[(x + N[Log[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \log x
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 99.3%
+-commutative99.3%
neg-mul-199.3%
unsub-neg99.3%
neg-mul-199.3%
Simplified99.3%
Final simplification99.3%
(FPCore (x) :precision binary64 (- (log -1.0)))
double code(double x) {
return -log(-1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = -log((-1.0d0))
end function
public static double code(double x) {
return -Math.log(-1.0);
}
def code(x): return -math.log(-1.0)
function code(x) return Float64(-log(-1.0)) end
function tmp = code(x) tmp = -log(-1.0); end
code[x_] := (-N[Log[-1.0], $MachinePrecision])
\begin{array}{l}
\\
-\log -1
\end{array}
Initial program 99.9%
Taylor expanded in x around inf 0.0%
Final simplification0.0%
(FPCore (x) :precision binary64 (log x))
double code(double x) {
return log(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = log(x)
end function
public static double code(double x) {
return Math.log(x);
}
def code(x): return math.log(x)
function code(x) return log(x) end
function tmp = code(x) tmp = log(x); end
code[x_] := N[Log[x], $MachinePrecision]
\begin{array}{l}
\\
\log x
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 98.9%
neg-mul-198.9%
Simplified98.9%
Final simplification98.9%
herbie shell --seed 2023318
(FPCore (x)
:name "neg log"
:precision binary64
(- (log (- (/ 1.0 x) 1.0))))