(FPCore (x y) :precision binary64 (log (- x y)))
double code(double x, double y) { return log((x - y)); }
real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y code = log((x - y)) end function
public static double code(double x, double y) { return Math.log((x - y)); }
def code(x, y): return math.log((x - y))
function code(x, y) return log(Float64(x - y)) end
function tmp = code(x, y) tmp = log((x - y)); end
code[x_, y_] := N[Log[N[(x - y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ \log \left(x - y\right) \end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x y) :precision binary64 (log (- x y)))
double code(double x, double y) { return log((x - y)); }
real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y code = log((x - y)) end function
public static double code(double x, double y) { return Math.log((x - y)); }
def code(x, y): return math.log((x - y))
function code(x, y) return log(Float64(x - y)) end
function tmp = code(x, y) tmp = log((x - y)); end
code[x_, y_] := N[Log[N[(x - y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ \log \left(x - y\right) \end{array}
(FPCore (x y) :precision binary64 (log (- x y)))
double code(double x, double y) { return log((x - y)); }
real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y code = log((x - y)) end function
public static double code(double x, double y) { return Math.log((x - y)); }
def code(x, y): return math.log((x - y))
function code(x, y) return log(Float64(x - y)) end
function tmp = code(x, y) tmp = log((x - y)); end
code[x_, y_] := N[Log[N[(x - y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ \log \left(x - y\right) \end{array}
Initial program 100.0%
(FPCore (x y) :precision binary64 (if (<= y -2.3e-216) (log (- y)) (log x)))
double code(double x, double y) { double tmp; if (y <= -2.3e-216) { tmp = log(-y); } else { tmp = log(x); } return tmp; }
real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y real(8) :: tmp if (y <= (-2.3d-216)) then tmp = log(-y) else tmp = log(x) end if code = tmp end function
public static double code(double x, double y) { double tmp; if (y <= -2.3e-216) { tmp = Math.log(-y); } else { tmp = Math.log(x); } return tmp; }
def code(x, y): tmp = 0 if y <= -2.3e-216: tmp = math.log(-y) else: tmp = math.log(x) return tmp
function code(x, y) tmp = 0.0 if (y <= -2.3e-216) tmp = log(Float64(-y)); else tmp = log(x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.3e-216) tmp = log(-y); else tmp = log(x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.3e-216], N[Log[(-y)], $MachinePrecision], N[Log[x], $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.3 \cdot 10^{-216}:\\ \;\;\;\;\log \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;\log x\\ \end{array} \end{array}
if y < -2.29999999999999997e-216
Initial program 100.0%
Taylor expanded in x around 0
neg-mul-1
N/A
lower-neg.f64
83.1
Applied rewrites83.1%
if -2.29999999999999997e-216 < y
Initial program 100.0%
Taylor expanded in x around inf
mul-1-neg
N/A
log-rec
N/A
remove-double-neg
N/A
lower-log.f64
89.7
Applied rewrites89.7%
(FPCore (x y) :precision binary64 (log x))
double code(double x, double y) { return log(x); }
real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y code = log(x) end function
public static double code(double x, double y) { return Math.log(x); }
def code(x, y): return math.log(x)
function code(x, y) return log(x) end
function tmp = code(x, y) tmp = log(x); end
code[x_, y_] := N[Log[x], $MachinePrecision]
\begin{array}{l} \\ \log x \end{array}
Initial program 100.0%
Taylor expanded in x around inf
mul-1-neg
N/A
log-rec
N/A
remove-double-neg
N/A
lower-log.f64
50.7
Applied rewrites50.7%
herbie shell --seed 1
(FPCore (x y)
:name "log(x - y) "
:precision binary64
:pre (and (and (<= -1000.0 x) (<= x 1000.0)) (and (<= -1000.0 y) (<= y 1000.0)))
(log (- x y)))