(FPCore (x y) :precision binary64 (log (/ (- (exp x) (exp y)) 2.0)))
double code(double x, double y) { return log(((exp(x) - exp(y)) / 2.0)); }
real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y code = log(((exp(x) - exp(y)) / 2.0d0)) end function
public static double code(double x, double y) { return Math.log(((Math.exp(x) - Math.exp(y)) / 2.0)); }
def code(x, y): return math.log(((math.exp(x) - math.exp(y)) / 2.0))
function code(x, y) return log(Float64(Float64(exp(x) - exp(y)) / 2.0)) end
function tmp = code(x, y) tmp = log(((exp(x) - exp(y)) / 2.0)); end
code[x_, y_] := N[Log[N[(N[(N[Exp[x], $MachinePrecision] - N[Exp[y], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ \log \left(\frac{e^{x} - e^{y}}{2}\right) \end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x y) :precision binary64 (log (/ (- (exp x) (exp y)) 2.0)))
double code(double x, double y) { return log(((exp(x) - exp(y)) / 2.0)); }
real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y code = log(((exp(x) - exp(y)) / 2.0d0)) end function
public static double code(double x, double y) { return Math.log(((Math.exp(x) - Math.exp(y)) / 2.0)); }
def code(x, y): return math.log(((math.exp(x) - math.exp(y)) / 2.0))
function code(x, y) return log(Float64(Float64(exp(x) - exp(y)) / 2.0)) end
function tmp = code(x, y) tmp = log(((exp(x) - exp(y)) / 2.0)); end
code[x_, y_] := N[Log[N[(N[(N[Exp[x], $MachinePrecision] - N[Exp[y], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ \log \left(\frac{e^{x} - e^{y}}{2}\right) \end{array}
(FPCore (x y) :precision binary64 (if (<= (- (exp x) (exp y)) 0.2) (log (* (fma (* (fma 0.16666666666666666 x 0.5) x) x (- x (expm1 y))) 0.5)) (log (* (- (exp y) (exp x)) -0.5))))
double code(double x, double y) { double tmp; if ((exp(x) - exp(y)) <= 0.2) { tmp = log((fma((fma(0.16666666666666666, x, 0.5) * x), x, (x - expm1(y))) * 0.5)); } else { tmp = log(((exp(y) - exp(x)) * -0.5)); } return tmp; }
function code(x, y) tmp = 0.0 if (Float64(exp(x) - exp(y)) <= 0.2) tmp = log(Float64(fma(Float64(fma(0.16666666666666666, x, 0.5) * x), x, Float64(x - expm1(y))) * 0.5)); else tmp = log(Float64(Float64(exp(y) - exp(x)) * -0.5)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[Exp[x], $MachinePrecision] - N[Exp[y], $MachinePrecision]), $MachinePrecision], 0.2], N[Log[N[(N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x), $MachinePrecision] * x + N[(x - N[(Exp[y] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], N[Log[N[(N[(N[Exp[y], $MachinePrecision] - N[Exp[x], $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{x} - e^{y} \leq 0.2:\\ \;\;\;\;\log \left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right) \cdot x, x, x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\left(e^{y} - e^{x}\right) \cdot -0.5\right)\\ \end{array} \end{array}
if (-.f64 (exp.f64 x) (exp.f64 y)) < 0.20000000000000001
Initial program 7.0%
Taylor expanded in x around 0
+-commutative
N/A
associate--l+
N/A
+-commutative
N/A
distribute-lft-in
N/A
*-rgt-identity
N/A
associate-+l+
N/A
associate-*r*
N/A
lower-fma.f64
N/A
lower-*.f64
N/A
+-commutative
N/A
lower-fma.f64
N/A
sub-neg
N/A
+-commutative
N/A
associate-+r+
N/A
sub-neg
N/A
associate-+l-
N/A
lower--.f64
N/A
lower-expm1.f64
99.1
Applied rewrites99.1%
lift-/.f64
N/A
div-inv
N/A
metadata-eval
N/A
lower-*.f64
99.1
Applied rewrites99.1%
if 0.20000000000000001 < (-.f64 (exp.f64 x) (exp.f64 y))
Initial program 98.6%
lift-/.f64
N/A
frac-2neg
N/A
div-inv
N/A
lower-*.f64
N/A
neg-sub0
N/A
metadata-eval
N/A
lift--.f64
N/A
sub-neg
N/A
+-commutative
N/A
associate--r+
N/A
metadata-eval
N/A
neg-sub0
N/A
remove-double-neg
N/A
lower--.f64
N/A
metadata-eval
N/A
metadata-eval
98.6
Applied rewrites98.6%
(FPCore (x y) :precision binary64 (if (<= (- (exp x) (exp y)) 2e-12) (log (* (fma (fma (fma -0.16666666666666666 y -0.5) y -1.0) y x) 0.5)) (log (* (expm1 x) 0.5))))
double code(double x, double y) { double tmp; if ((exp(x) - exp(y)) <= 2e-12) { tmp = log((fma(fma(fma(-0.16666666666666666, y, -0.5), y, -1.0), y, x) * 0.5)); } else { tmp = log((expm1(x) * 0.5)); } return tmp; }
function code(x, y) tmp = 0.0 if (Float64(exp(x) - exp(y)) <= 2e-12) tmp = log(Float64(fma(fma(fma(-0.16666666666666666, y, -0.5), y, -1.0), y, x) * 0.5)); else tmp = log(Float64(expm1(x) * 0.5)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[Exp[x], $MachinePrecision] - N[Exp[y], $MachinePrecision]), $MachinePrecision], 2e-12], N[Log[N[(N[(N[(N[(-0.16666666666666666 * y + -0.5), $MachinePrecision] * y + -1.0), $MachinePrecision] * y + x), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], N[Log[N[(N[(Exp[x] - 1), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{x} - e^{y} \leq 2 \cdot 10^{-12}:\\ \;\;\;\;\log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5\right), y, -1\right), y, x\right) \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\mathsf{expm1}\left(x\right) \cdot 0.5\right)\\ \end{array} \end{array}
if (-.f64 (exp.f64 x) (exp.f64 y)) < 1.99999999999999996e-12
Initial program 4.5%
Taylor expanded in x around 0
distribute-lft-out
N/A
*-commutative
N/A
lower-*.f64
N/A
sub-neg
N/A
+-commutative
N/A
associate-+r+
N/A
sub-neg
N/A
associate-+l-
N/A
lower--.f64
N/A
lower-expm1.f64
99.1
Applied rewrites99.1%
Taylor expanded in y around 0
Applied rewrites99.1%
if 1.99999999999999996e-12 < (-.f64 (exp.f64 x) (exp.f64 y))
Initial program 98.0%
Taylor expanded in y around 0
*-commutative
N/A
lower-*.f64
N/A
lower-expm1.f64
11.4
Applied rewrites11.4%
(FPCore (x y) :precision binary64 (if (<= (- (exp x) (exp y)) 0.5) (log (* (fma (fma (fma -0.16666666666666666 y -0.5) y -1.0) y x) 0.5)) (log (* (* (fma 0.08333333333333333 x 0.25) x) x))))
double code(double x, double y) { double tmp; if ((exp(x) - exp(y)) <= 0.5) { tmp = log((fma(fma(fma(-0.16666666666666666, y, -0.5), y, -1.0), y, x) * 0.5)); } else { tmp = log(((fma(0.08333333333333333, x, 0.25) * x) * x)); } return tmp; }
function code(x, y) tmp = 0.0 if (Float64(exp(x) - exp(y)) <= 0.5) tmp = log(Float64(fma(fma(fma(-0.16666666666666666, y, -0.5), y, -1.0), y, x) * 0.5)); else tmp = log(Float64(Float64(fma(0.08333333333333333, x, 0.25) * x) * x)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[Exp[x], $MachinePrecision] - N[Exp[y], $MachinePrecision]), $MachinePrecision], 0.5], N[Log[N[(N[(N[(N[(-0.16666666666666666 * y + -0.5), $MachinePrecision] * y + -1.0), $MachinePrecision] * y + x), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], N[Log[N[(N[(N[(0.08333333333333333 * x + 0.25), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{x} - e^{y} \leq 0.5:\\ \;\;\;\;\log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5\right), y, -1\right), y, x\right) \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right) \cdot x\right) \cdot x\right)\\ \end{array} \end{array}
if (-.f64 (exp.f64 x) (exp.f64 y)) < 0.5
Initial program 7.8%
Taylor expanded in x around 0
distribute-lft-out
N/A
*-commutative
N/A
lower-*.f64
N/A
sub-neg
N/A
+-commutative
N/A
associate-+r+
N/A
sub-neg
N/A
associate-+l-
N/A
lower--.f64
N/A
lower-expm1.f64
98.2
Applied rewrites98.2%
Taylor expanded in y around 0
Applied rewrites97.2%
if 0.5 < (-.f64 (exp.f64 x) (exp.f64 y))
Initial program 98.5%
Taylor expanded in x around 0
+-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
+-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
+-commutative
N/A
lower-fma.f64
N/A
sub-neg
N/A
+-commutative
N/A
distribute-lft-in
N/A
neg-mul-1
N/A
associate-*r*
N/A
metadata-eval
N/A
metadata-eval
N/A
lower-fma.f64
N/A
lower-exp.f64
95.3
Applied rewrites95.3%
Taylor expanded in x around inf
Applied rewrites8.6%
(FPCore (x y) :precision binary64 (if (<= (- (exp x) (exp y)) 0.5) (log (* (- x y) 0.5)) (log (* (* (fma 0.08333333333333333 x 0.25) x) x))))
double code(double x, double y) { double tmp; if ((exp(x) - exp(y)) <= 0.5) { tmp = log(((x - y) * 0.5)); } else { tmp = log(((fma(0.08333333333333333, x, 0.25) * x) * x)); } return tmp; }
function code(x, y) tmp = 0.0 if (Float64(exp(x) - exp(y)) <= 0.5) tmp = log(Float64(Float64(x - y) * 0.5)); else tmp = log(Float64(Float64(fma(0.08333333333333333, x, 0.25) * x) * x)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[Exp[x], $MachinePrecision] - N[Exp[y], $MachinePrecision]), $MachinePrecision], 0.5], N[Log[N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], N[Log[N[(N[(N[(0.08333333333333333 * x + 0.25), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{x} - e^{y} \leq 0.5:\\ \;\;\;\;\log \left(\left(x - y\right) \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right) \cdot x\right) \cdot x\right)\\ \end{array} \end{array}
if (-.f64 (exp.f64 x) (exp.f64 y)) < 0.5
Initial program 7.8%
Taylor expanded in x around 0
distribute-lft-out
N/A
*-commutative
N/A
lower-*.f64
N/A
sub-neg
N/A
+-commutative
N/A
associate-+r+
N/A
sub-neg
N/A
associate-+l-
N/A
lower--.f64
N/A
lower-expm1.f64
98.2
Applied rewrites98.2%
Taylor expanded in y around 0
Applied rewrites96.9%
if 0.5 < (-.f64 (exp.f64 x) (exp.f64 y))
Initial program 98.5%
Taylor expanded in x around 0
+-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
+-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
+-commutative
N/A
lower-fma.f64
N/A
sub-neg
N/A
+-commutative
N/A
distribute-lft-in
N/A
neg-mul-1
N/A
associate-*r*
N/A
metadata-eval
N/A
metadata-eval
N/A
lower-fma.f64
N/A
lower-exp.f64
95.3
Applied rewrites95.3%
Taylor expanded in x around inf
Applied rewrites8.6%
(FPCore (x y) :precision binary64 (if (<= (- (exp x) (exp y)) 2e-12) (log (* (- x y) 0.5)) (log (* (fma 0.25 x 0.5) x))))
double code(double x, double y) { double tmp; if ((exp(x) - exp(y)) <= 2e-12) { tmp = log(((x - y) * 0.5)); } else { tmp = log((fma(0.25, x, 0.5) * x)); } return tmp; }
function code(x, y) tmp = 0.0 if (Float64(exp(x) - exp(y)) <= 2e-12) tmp = log(Float64(Float64(x - y) * 0.5)); else tmp = log(Float64(fma(0.25, x, 0.5) * x)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[Exp[x], $MachinePrecision] - N[Exp[y], $MachinePrecision]), $MachinePrecision], 2e-12], N[Log[N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], N[Log[N[(N[(0.25 * x + 0.5), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{x} - e^{y} \leq 2 \cdot 10^{-12}:\\ \;\;\;\;\log \left(\left(x - y\right) \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\mathsf{fma}\left(0.25, x, 0.5\right) \cdot x\right)\\ \end{array} \end{array}
if (-.f64 (exp.f64 x) (exp.f64 y)) < 1.99999999999999996e-12
Initial program 4.5%
Taylor expanded in x around 0
distribute-lft-out
N/A
*-commutative
N/A
lower-*.f64
N/A
sub-neg
N/A
+-commutative
N/A
associate-+r+
N/A
sub-neg
N/A
associate-+l-
N/A
lower--.f64
N/A
lower-expm1.f64
99.1
Applied rewrites99.1%
Taylor expanded in y around 0
Applied rewrites99.0%
if 1.99999999999999996e-12 < (-.f64 (exp.f64 x) (exp.f64 y))
Initial program 98.0%
Taylor expanded in y around 0
*-commutative
N/A
lower-*.f64
N/A
lower-expm1.f64
11.4
Applied rewrites11.4%
Taylor expanded in x around 0
Applied rewrites9.0%
(FPCore (x y) :precision binary64 (if (<= (- (exp x) (exp y)) 0.51) (log (* (- x y) 0.5)) (log (* 0.5 x))))
double code(double x, double y) { double tmp; if ((exp(x) - exp(y)) <= 0.51) { tmp = log(((x - y) * 0.5)); } else { tmp = log((0.5 * x)); } return tmp; }
real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y real(8) :: tmp if ((exp(x) - exp(y)) <= 0.51d0) then tmp = log(((x - y) * 0.5d0)) else tmp = log((0.5d0 * x)) end if code = tmp end function
public static double code(double x, double y) { double tmp; if ((Math.exp(x) - Math.exp(y)) <= 0.51) { tmp = Math.log(((x - y) * 0.5)); } else { tmp = Math.log((0.5 * x)); } return tmp; }
def code(x, y): tmp = 0 if (math.exp(x) - math.exp(y)) <= 0.51: tmp = math.log(((x - y) * 0.5)) else: tmp = math.log((0.5 * x)) return tmp
function code(x, y) tmp = 0.0 if (Float64(exp(x) - exp(y)) <= 0.51) tmp = log(Float64(Float64(x - y) * 0.5)); else tmp = log(Float64(0.5 * x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((exp(x) - exp(y)) <= 0.51) tmp = log(((x - y) * 0.5)); else tmp = log((0.5 * x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[Exp[x], $MachinePrecision] - N[Exp[y], $MachinePrecision]), $MachinePrecision], 0.51], N[Log[N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], N[Log[N[(0.5 * x), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{x} - e^{y} \leq 0.51:\\ \;\;\;\;\log \left(\left(x - y\right) \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(0.5 \cdot x\right)\\ \end{array} \end{array}
if (-.f64 (exp.f64 x) (exp.f64 y)) < 0.51000000000000001
Initial program 8.5%
Taylor expanded in x around 0
distribute-lft-out
N/A
*-commutative
N/A
lower-*.f64
N/A
sub-neg
N/A
+-commutative
N/A
associate-+r+
N/A
sub-neg
N/A
associate-+l-
N/A
lower--.f64
N/A
lower-expm1.f64
97.5
Applied rewrites97.5%
Taylor expanded in y around 0
Applied rewrites96.1%
if 0.51000000000000001 < (-.f64 (exp.f64 x) (exp.f64 y))
Initial program 98.5%
Taylor expanded in y around 0
*-commutative
N/A
lower-*.f64
N/A
lower-expm1.f64
9.5
Applied rewrites9.5%
Taylor expanded in x around 0
Applied rewrites7.2%
(FPCore (x y) :precision binary64 (if (<= (exp y) 0.9) (log (fma -0.5 (exp y) 0.5)) (log (* (fma (fma -0.5 y -1.0) y x) 0.5))))
double code(double x, double y) { double tmp; if (exp(y) <= 0.9) { tmp = log(fma(-0.5, exp(y), 0.5)); } else { tmp = log((fma(fma(-0.5, y, -1.0), y, x) * 0.5)); } return tmp; }
function code(x, y) tmp = 0.0 if (exp(y) <= 0.9) tmp = log(fma(-0.5, exp(y), 0.5)); else tmp = log(Float64(fma(fma(-0.5, y, -1.0), y, x) * 0.5)); end return tmp end
code[x_, y_] := If[LessEqual[N[Exp[y], $MachinePrecision], 0.9], N[Log[N[(-0.5 * N[Exp[y], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision], N[Log[N[(N[(N[(-0.5 * y + -1.0), $MachinePrecision] * y + x), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{y} \leq 0.9:\\ \;\;\;\;\log \left(\mathsf{fma}\left(-0.5, e^{y}, 0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.5, y, -1\right), y, x\right) \cdot 0.5\right)\\ \end{array} \end{array}
if (exp.f64 y) < 0.900000000000000022
Initial program 97.8%
Taylor expanded in x around 0
sub-neg
N/A
+-commutative
N/A
distribute-lft-in
N/A
neg-mul-1
N/A
associate-*r*
N/A
metadata-eval
N/A
metadata-eval
N/A
lower-fma.f64
N/A
lower-exp.f64
94.5
Applied rewrites94.5%
if 0.900000000000000022 < (exp.f64 y)
Initial program 9.4%
Taylor expanded in x around 0
distribute-lft-out
N/A
*-commutative
N/A
lower-*.f64
N/A
sub-neg
N/A
+-commutative
N/A
associate-+r+
N/A
sub-neg
N/A
associate-+l-
N/A
lower--.f64
N/A
lower-expm1.f64
96.3
Applied rewrites96.3%
Taylor expanded in y around 0
Applied rewrites96.3%
(FPCore (x y) :precision binary64 (if (<= (exp y) 0.1) (log (* (* (fma 0.08333333333333333 x 0.25) x) x)) (log (* (- x (* (fma (fma (fma 0.041666666666666664 y 0.16666666666666666) y 0.5) y 1.0) y)) 0.5))))
double code(double x, double y) { double tmp; if (exp(y) <= 0.1) { tmp = log(((fma(0.08333333333333333, x, 0.25) * x) * x)); } else { tmp = log(((x - (fma(fma(fma(0.041666666666666664, y, 0.16666666666666666), y, 0.5), y, 1.0) * y)) * 0.5)); } return tmp; }
function code(x, y) tmp = 0.0 if (exp(y) <= 0.1) tmp = log(Float64(Float64(fma(0.08333333333333333, x, 0.25) * x) * x)); else tmp = log(Float64(Float64(x - Float64(fma(fma(fma(0.041666666666666664, y, 0.16666666666666666), y, 0.5), y, 1.0) * y)) * 0.5)); end return tmp end
code[x_, y_] := If[LessEqual[N[Exp[y], $MachinePrecision], 0.1], N[Log[N[(N[(N[(0.08333333333333333 * x + 0.25), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision], N[Log[N[(N[(x - N[(N[(N[(N[(0.041666666666666664 * y + 0.16666666666666666), $MachinePrecision] * y + 0.5), $MachinePrecision] * y + 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{y} \leq 0.1:\\ \;\;\;\;\log \left(\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right) \cdot x\right) \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\left(x - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, y, 0.16666666666666666\right), y, 0.5\right), y, 1\right) \cdot y\right) \cdot 0.5\right)\\ \end{array} \end{array}
if (exp.f64 y) < 0.10000000000000001
Initial program 97.8%
Taylor expanded in x around 0
+-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
+-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
+-commutative
N/A
lower-fma.f64
N/A
sub-neg
N/A
+-commutative
N/A
distribute-lft-in
N/A
neg-mul-1
N/A
associate-*r*
N/A
metadata-eval
N/A
metadata-eval
N/A
lower-fma.f64
N/A
lower-exp.f64
96.8
Applied rewrites96.8%
Taylor expanded in x around inf
Applied rewrites8.3%
if 0.10000000000000001 < (exp.f64 y)
Initial program 10.8%
Taylor expanded in x around 0
distribute-lft-out
N/A
*-commutative
N/A
lower-*.f64
N/A
sub-neg
N/A
+-commutative
N/A
associate-+r+
N/A
sub-neg
N/A
associate-+l-
N/A
lower--.f64
N/A
lower-expm1.f64
96.4
Applied rewrites96.4%
Taylor expanded in y around 0
Applied rewrites95.4%
(FPCore (x y) :precision binary64 (log (* (fma (* (fma 0.16666666666666666 x 0.5) x) x (- x (expm1 y))) 0.5)))
double code(double x, double y) { return log((fma((fma(0.16666666666666666, x, 0.5) * x), x, (x - expm1(y))) * 0.5)); }
function code(x, y) return log(Float64(fma(Float64(fma(0.16666666666666666, x, 0.5) * x), x, Float64(x - expm1(y))) * 0.5)) end
code[x_, y_] := N[Log[N[(N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x), $MachinePrecision] * x + N[(x - N[(Exp[y] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ \log \left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right) \cdot x, x, x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right) \end{array}
Initial program 56.0%
Taylor expanded in x around 0
+-commutative
N/A
associate--l+
N/A
+-commutative
N/A
distribute-lft-in
N/A
*-rgt-identity
N/A
associate-+l+
N/A
associate-*r*
N/A
lower-fma.f64
N/A
lower-*.f64
N/A
+-commutative
N/A
lower-fma.f64
N/A
sub-neg
N/A
+-commutative
N/A
associate-+r+
N/A
sub-neg
N/A
associate-+l-
N/A
lower--.f64
N/A
lower-expm1.f64
97.1
Applied rewrites97.1%
lift-/.f64
N/A
div-inv
N/A
metadata-eval
N/A
lower-*.f64
97.1
Applied rewrites97.1%
(FPCore (x y) :precision binary64 (if (<= (exp y) 0.1) (log (* (* (fma 0.08333333333333333 x 0.25) x) x)) (log (* (fma (fma -0.5 y -1.0) y x) 0.5))))
double code(double x, double y) { double tmp; if (exp(y) <= 0.1) { tmp = log(((fma(0.08333333333333333, x, 0.25) * x) * x)); } else { tmp = log((fma(fma(-0.5, y, -1.0), y, x) * 0.5)); } return tmp; }
function code(x, y) tmp = 0.0 if (exp(y) <= 0.1) tmp = log(Float64(Float64(fma(0.08333333333333333, x, 0.25) * x) * x)); else tmp = log(Float64(fma(fma(-0.5, y, -1.0), y, x) * 0.5)); end return tmp end
code[x_, y_] := If[LessEqual[N[Exp[y], $MachinePrecision], 0.1], N[Log[N[(N[(N[(0.08333333333333333 * x + 0.25), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision], N[Log[N[(N[(N[(-0.5 * y + -1.0), $MachinePrecision] * y + x), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{y} \leq 0.1:\\ \;\;\;\;\log \left(\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right) \cdot x\right) \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.5, y, -1\right), y, x\right) \cdot 0.5\right)\\ \end{array} \end{array}
if (exp.f64 y) < 0.10000000000000001
Initial program 97.8%
Taylor expanded in x around 0
+-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
+-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
+-commutative
N/A
lower-fma.f64
N/A
sub-neg
N/A
+-commutative
N/A
distribute-lft-in
N/A
neg-mul-1
N/A
associate-*r*
N/A
metadata-eval
N/A
metadata-eval
N/A
lower-fma.f64
N/A
lower-exp.f64
96.8
Applied rewrites96.8%
Taylor expanded in x around inf
Applied rewrites8.3%
if 0.10000000000000001 < (exp.f64 y)
Initial program 10.8%
Taylor expanded in x around 0
distribute-lft-out
N/A
*-commutative
N/A
lower-*.f64
N/A
sub-neg
N/A
+-commutative
N/A
associate-+r+
N/A
sub-neg
N/A
associate-+l-
N/A
lower--.f64
N/A
lower-expm1.f64
96.4
Applied rewrites96.4%
Taylor expanded in y around 0
Applied rewrites95.2%
(FPCore (x y) :precision binary64 (log (* (- x (expm1 y)) 0.5)))
double code(double x, double y) { return log(((x - expm1(y)) * 0.5)); }
public static double code(double x, double y) { return Math.log(((x - Math.expm1(y)) * 0.5)); }
def code(x, y): return math.log(((x - math.expm1(y)) * 0.5))
function code(x, y) return log(Float64(Float64(x - expm1(y)) * 0.5)) end
code[x_, y_] := N[Log[N[(N[(x - N[(Exp[y] - 1), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ \log \left(\left(x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right) \end{array}
Initial program 56.0%
Taylor expanded in x around 0
distribute-lft-out
N/A
*-commutative
N/A
lower-*.f64
N/A
sub-neg
N/A
+-commutative
N/A
associate-+r+
N/A
sub-neg
N/A
associate-+l-
N/A
lower--.f64
N/A
lower-expm1.f64
96.2
Applied rewrites96.2%
(FPCore (x y) :precision binary64 (if (<= x -5e-310) (/ x (- y)) (log (* 0.5 x))))
double code(double x, double y) { double tmp; if (x <= -5e-310) { tmp = x / -y; } else { tmp = log((0.5 * x)); } return tmp; }
real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y real(8) :: tmp if (x <= (-5d-310)) then tmp = x / -y else tmp = log((0.5d0 * x)) end if code = tmp end function
public static double code(double x, double y) { double tmp; if (x <= -5e-310) { tmp = x / -y; } else { tmp = Math.log((0.5 * x)); } return tmp; }
def code(x, y): tmp = 0 if x <= -5e-310: tmp = x / -y else: tmp = math.log((0.5 * x)) return tmp
function code(x, y) tmp = 0.0 if (x <= -5e-310) tmp = Float64(x / Float64(-y)); else tmp = log(Float64(0.5 * x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5e-310) tmp = x / -y; else tmp = log((0.5 * x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5e-310], N[(x / (-y)), $MachinePrecision], N[Log[N[(0.5 * x), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{x}{-y}\\ \mathbf{else}:\\ \;\;\;\;\log \left(0.5 \cdot x\right)\\ \end{array} \end{array}
if x < -4.999999999999985e-310
Initial program 72.9%
Taylor expanded in x around 0
+-commutative
N/A
*-rgt-identity
N/A
associate-*r/
N/A
lower-+.f64
N/A
associate-*r/
N/A
*-rgt-identity
N/A
lower-/.f64
N/A
sub-neg
N/A
+-commutative
N/A
neg-sub0
N/A
associate-+l-
N/A
sub0-neg
N/A
lower-neg.f64
N/A
lower-expm1.f64
N/A
lower-log.f64
N/A
sub-neg
N/A
+-commutative
N/A
distribute-lft-in
N/A
neg-mul-1
N/A
associate-*r*
N/A
metadata-eval
N/A
metadata-eval
N/A
Applied rewrites73.9%
Taylor expanded in y around 0
Applied rewrites4.6%
if -4.999999999999985e-310 < x
Initial program 46.4%
Taylor expanded in y around 0
*-commutative
N/A
lower-*.f64
N/A
lower-expm1.f64
53.7
Applied rewrites53.7%
Taylor expanded in x around 0
Applied rewrites51.0%
(FPCore (x y) :precision binary64 (/ x (- y)))
double code(double x, double y) { return x / -y; }
real(8) function code(x, y) real(8), intent (in) :: x real(8), intent (in) :: y code = x / -y end function
public static double code(double x, double y) { return x / -y; }
def code(x, y): return x / -y
function code(x, y) return Float64(x / Float64(-y)) end
function tmp = code(x, y) tmp = x / -y; end
code[x_, y_] := N[(x / (-y)), $MachinePrecision]
\begin{array}{l} \\ \frac{x}{-y} \end{array}
Initial program 56.0%
Taylor expanded in x around 0
+-commutative
N/A
*-rgt-identity
N/A
associate-*r/
N/A
lower-+.f64
N/A
associate-*r/
N/A
*-rgt-identity
N/A
lower-/.f64
N/A
sub-neg
N/A
+-commutative
N/A
neg-sub0
N/A
associate-+l-
N/A
sub0-neg
N/A
lower-neg.f64
N/A
lower-expm1.f64
N/A
lower-log.f64
N/A
sub-neg
N/A
+-commutative
N/A
distribute-lft-in
N/A
neg-mul-1
N/A
associate-*r*
N/A
metadata-eval
N/A
metadata-eval
N/A
Applied rewrites54.4%
Taylor expanded in y around 0
Applied rewrites3.7%
herbie shell --seed 1
(FPCore (x y)
:name "log((exp(x) - exp(y))/2)"
:precision binary64
:pre (and (and (<= -1.79e+308 x) (<= x 1.79e+308)) (and (<= -1.79e+308 y) (<= y 1.79e+308)))
(log (/ (- (exp x) (exp y)) 2.0)))