
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + y) - z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - ((y + 0.5) * log(y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + y) - z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - ((y + 0.5) * log(y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + y) - z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - ((y + 0.5) * log(y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}
Initial program 99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- x (* (+ y 0.5) (log y))) y)))
(if (<= t_0 -1e+141)
(fma (- -0.5 y) (log y) (+ x y))
(if (<= t_0 2.0)
(- y (fma (+ 0.5 y) (log y) z))
(- (fma -0.5 (log y) x) z)))))
double code(double x, double y, double z) {
double t_0 = (x - ((y + 0.5) * log(y))) + y;
double tmp;
if (t_0 <= -1e+141) {
tmp = fma((-0.5 - y), log(y), (x + y));
} else if (t_0 <= 2.0) {
tmp = y - fma((0.5 + y), log(y), z);
} else {
tmp = fma(-0.5, log(y), x) - z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) tmp = 0.0 if (t_0 <= -1e+141) tmp = fma(Float64(-0.5 - y), log(y), Float64(x + y)); elseif (t_0 <= 2.0) tmp = Float64(y - fma(Float64(0.5 + y), log(y), z)); else tmp = Float64(fma(-0.5, log(y), x) - z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+141], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(y - N[(N[(0.5 + y), $MachinePrecision] * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - \left(y + 0.5\right) \cdot \log y\right) + y\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+141}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, x + y\right)\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;y - \mathsf{fma}\left(0.5 + y, \log y, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -1.00000000000000002e141Initial program 99.6%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.6
lift--.f64N/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in z around 0
mul-1-negN/A
sub-negN/A
associate--l+N/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites91.7%
if -1.00000000000000002e141 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 2Initial program 99.8%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6488.2
Applied rewrites88.2%
if 2 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
*-commutativeN/A
cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-neg-inN/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6499.8
Applied rewrites99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (+ (- x (* (+ y 0.5) (log y))) y) z)))
(if (or (<= t_0 -10000.0) (not (<= t_0 500.0)))
(- (+ (* 1.0 x) y) z)
(* -0.5 (log y)))))
double code(double x, double y, double z) {
double t_0 = ((x - ((y + 0.5) * log(y))) + y) - z;
double tmp;
if ((t_0 <= -10000.0) || !(t_0 <= 500.0)) {
tmp = ((1.0 * x) + y) - z;
} else {
tmp = -0.5 * log(y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((x - ((y + 0.5d0) * log(y))) + y) - z
if ((t_0 <= (-10000.0d0)) .or. (.not. (t_0 <= 500.0d0))) then
tmp = ((1.0d0 * x) + y) - z
else
tmp = (-0.5d0) * log(y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((x - ((y + 0.5) * Math.log(y))) + y) - z;
double tmp;
if ((t_0 <= -10000.0) || !(t_0 <= 500.0)) {
tmp = ((1.0 * x) + y) - z;
} else {
tmp = -0.5 * Math.log(y);
}
return tmp;
}
def code(x, y, z): t_0 = ((x - ((y + 0.5) * math.log(y))) + y) - z tmp = 0 if (t_0 <= -10000.0) or not (t_0 <= 500.0): tmp = ((1.0 * x) + y) - z else: tmp = -0.5 * math.log(y) return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) tmp = 0.0 if ((t_0 <= -10000.0) || !(t_0 <= 500.0)) tmp = Float64(Float64(Float64(1.0 * x) + y) - z); else tmp = Float64(-0.5 * log(y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((x - ((y + 0.5) * log(y))) + y) - z; tmp = 0.0; if ((t_0 <= -10000.0) || ~((t_0 <= 500.0))) tmp = ((1.0 * x) + y) - z; else tmp = -0.5 * log(y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -10000.0], N[Not[LessEqual[t$95$0, 500.0]], $MachinePrecision]], N[(N[(N[(1.0 * x), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision], N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z\\
\mathbf{if}\;t\_0 \leq -10000 \lor \neg \left(t\_0 \leq 500\right):\\
\;\;\;\;\left(1 \cdot x + y\right) - z\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \log y\\
\end{array}
\end{array}
if (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < -1e4 or 500 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) Initial program 99.8%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
flip3-+N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
lower-/.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
*-commutativeN/A
metadata-evalN/A
distribute-lft-inN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
neg-mul-1N/A
lower-*.f64N/A
Applied rewrites89.4%
Taylor expanded in x around inf
Applied rewrites64.4%
if -1e4 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < 500Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6497.7
Applied rewrites97.7%
Taylor expanded in z around inf
Applied rewrites97.3%
Taylor expanded in z around 0
Applied rewrites96.6%
Taylor expanded in y around 0
Applied rewrites91.8%
Final simplification68.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- x (* (+ y 0.5) (log y))) y)))
(if (<= t_0 2.0)
(fma (- -0.5 y) (log y) y)
(if (<= t_0 340.0) (- y (fma 0.5 (log y) z)) (- (+ (* 1.0 x) y) z)))))
double code(double x, double y, double z) {
double t_0 = (x - ((y + 0.5) * log(y))) + y;
double tmp;
if (t_0 <= 2.0) {
tmp = fma((-0.5 - y), log(y), y);
} else if (t_0 <= 340.0) {
tmp = y - fma(0.5, log(y), z);
} else {
tmp = ((1.0 * x) + y) - z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) tmp = 0.0 if (t_0 <= 2.0) tmp = fma(Float64(-0.5 - y), log(y), y); elseif (t_0 <= 340.0) tmp = Float64(y - fma(0.5, log(y), z)); else tmp = Float64(Float64(Float64(1.0 * x) + y) - z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$0, 2.0], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + y), $MachinePrecision], If[LessEqual[t$95$0, 340.0], N[(y - N[(0.5 * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 * x), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - \left(y + 0.5\right) \cdot \log y\right) + y\\
\mathbf{if}\;t\_0 \leq 2:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, y\right)\\
\mathbf{elif}\;t\_0 \leq 340:\\
\;\;\;\;y - \mathsf{fma}\left(0.5, \log y, z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \cdot x + y\right) - z\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 2Initial program 99.7%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6475.2
Applied rewrites75.2%
Taylor expanded in z around inf
Applied rewrites61.9%
Taylor expanded in z around 0
Applied rewrites58.0%
if 2 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 340Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6499.0
Applied rewrites99.0%
Taylor expanded in y around 0
Applied rewrites99.0%
if 340 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
flip3-+N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
lower-/.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
metadata-evalN/A
distribute-lft-inN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
neg-mul-1N/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites99.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- x (* (+ y 0.5) (log y))) y)))
(if (<= t_0 2.0)
(fma (- -0.5 y) (log y) y)
(if (<= t_0 340.0) (- (fma (log y) 0.5 z)) (- (+ (* 1.0 x) y) z)))))
double code(double x, double y, double z) {
double t_0 = (x - ((y + 0.5) * log(y))) + y;
double tmp;
if (t_0 <= 2.0) {
tmp = fma((-0.5 - y), log(y), y);
} else if (t_0 <= 340.0) {
tmp = -fma(log(y), 0.5, z);
} else {
tmp = ((1.0 * x) + y) - z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) tmp = 0.0 if (t_0 <= 2.0) tmp = fma(Float64(-0.5 - y), log(y), y); elseif (t_0 <= 340.0) tmp = Float64(-fma(log(y), 0.5, z)); else tmp = Float64(Float64(Float64(1.0 * x) + y) - z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$0, 2.0], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + y), $MachinePrecision], If[LessEqual[t$95$0, 340.0], (-N[(N[Log[y], $MachinePrecision] * 0.5 + z), $MachinePrecision]), N[(N[(N[(1.0 * x), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - \left(y + 0.5\right) \cdot \log y\right) + y\\
\mathbf{if}\;t\_0 \leq 2:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, y\right)\\
\mathbf{elif}\;t\_0 \leq 340:\\
\;\;\;\;-\mathsf{fma}\left(\log y, 0.5, z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \cdot x + y\right) - z\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 2Initial program 99.7%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6475.2
Applied rewrites75.2%
Taylor expanded in z around inf
Applied rewrites61.9%
Taylor expanded in z around 0
Applied rewrites58.0%
if 2 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 340Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6499.0
Applied rewrites99.0%
Taylor expanded in y around 0
Applied rewrites99.0%
if 340 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
flip3-+N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
lower-/.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
metadata-evalN/A
distribute-lft-inN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
neg-mul-1N/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites99.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- x (* (+ y 0.5) (log y))) y)))
(if (<= t_0 -5e+47)
(* (- 1.0 (log y)) y)
(if (<= t_0 340.0) (- (fma (log y) 0.5 z)) (- (+ (* 1.0 x) y) z)))))
double code(double x, double y, double z) {
double t_0 = (x - ((y + 0.5) * log(y))) + y;
double tmp;
if (t_0 <= -5e+47) {
tmp = (1.0 - log(y)) * y;
} else if (t_0 <= 340.0) {
tmp = -fma(log(y), 0.5, z);
} else {
tmp = ((1.0 * x) + y) - z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) tmp = 0.0 if (t_0 <= -5e+47) tmp = Float64(Float64(1.0 - log(y)) * y); elseif (t_0 <= 340.0) tmp = Float64(-fma(log(y), 0.5, z)); else tmp = Float64(Float64(Float64(1.0 * x) + y) - z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+47], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, 340.0], (-N[(N[Log[y], $MachinePrecision] * 0.5 + z), $MachinePrecision]), N[(N[(N[(1.0 * x), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - \left(y + 0.5\right) \cdot \log y\right) + y\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+47}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\mathbf{elif}\;t\_0 \leq 340:\\
\;\;\;\;-\mathsf{fma}\left(\log y, 0.5, z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \cdot x + y\right) - z\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -5.00000000000000022e47Initial program 99.7%
Taylor expanded in y around inf
*-commutativeN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6460.8
Applied rewrites60.8%
if -5.00000000000000022e47 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 340Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6493.9
Applied rewrites93.9%
Taylor expanded in y around 0
Applied rewrites85.8%
if 340 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
flip3-+N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
lower-/.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
metadata-evalN/A
distribute-lft-inN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
neg-mul-1N/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites99.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -230.0) (not (<= x 0.00095))) (- (+ (* 1.0 x) y) z) (- (fma (log y) 0.5 z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -230.0) || !(x <= 0.00095)) {
tmp = ((1.0 * x) + y) - z;
} else {
tmp = -fma(log(y), 0.5, z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((x <= -230.0) || !(x <= 0.00095)) tmp = Float64(Float64(Float64(1.0 * x) + y) - z); else tmp = Float64(-fma(log(y), 0.5, z)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[x, -230.0], N[Not[LessEqual[x, 0.00095]], $MachinePrecision]], N[(N[(N[(1.0 * x), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision], (-N[(N[Log[y], $MachinePrecision] * 0.5 + z), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -230 \lor \neg \left(x \leq 0.00095\right):\\
\;\;\;\;\left(1 \cdot x + y\right) - z\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(\log y, 0.5, z\right)\\
\end{array}
\end{array}
if x < -230 or 9.49999999999999998e-4 < x Initial program 99.9%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
flip3-+N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
lower-/.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in x around inf
*-commutativeN/A
metadata-evalN/A
distribute-lft-inN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
neg-mul-1N/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites78.1%
if -230 < x < 9.49999999999999998e-4Initial program 99.8%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6499.2
Applied rewrites99.2%
Taylor expanded in y around 0
Applied rewrites62.2%
Final simplification69.7%
(FPCore (x y z) :precision binary64 (if (<= y 3.3) (- (fma -0.5 (log y) x) z) (- (+ (- x (* (log y) y)) y) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.3) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = ((x - (log(y) * y)) + y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 3.3) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(Float64(Float64(x - Float64(log(y) * y)) + y) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 3.3], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(x - N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.3:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x - \log y \cdot y\right) + y\right) - z\\
\end{array}
\end{array}
if y < 3.2999999999999998Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
*-commutativeN/A
cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-neg-inN/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6498.8
Applied rewrites98.8%
if 3.2999999999999998 < y Initial program 99.6%
Taylor expanded in y around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
log-recN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6499.2
Applied rewrites99.2%
(FPCore (x y z) :precision binary64 (if (<= y 135000000000.0) (- (fma -0.5 (log y) x) z) (- y (fma (+ 0.5 y) (log y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 135000000000.0) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = y - fma((0.5 + y), log(y), z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 135000000000.0) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(y - fma(Float64(0.5 + y), log(y), z)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 135000000000.0], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(y - N[(N[(0.5 + y), $MachinePrecision] * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 135000000000:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;y - \mathsf{fma}\left(0.5 + y, \log y, z\right)\\
\end{array}
\end{array}
if y < 1.35e11Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
*-commutativeN/A
cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-neg-inN/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6498.2
Applied rewrites98.2%
if 1.35e11 < y Initial program 99.6%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6480.5
Applied rewrites80.5%
(FPCore (x y z) :precision binary64 (if (<= y 2.8e+132) (- (fma -0.5 (log y) x) z) (fma (- -0.5 y) (log y) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.8e+132) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = fma((-0.5 - y), log(y), y);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 2.8e+132) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = fma(Float64(-0.5 - y), log(y), y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 2.8e+132], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.8 \cdot 10^{+132}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, y\right)\\
\end{array}
\end{array}
if y < 2.7999999999999999e132Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
*-commutativeN/A
cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-neg-inN/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6488.2
Applied rewrites88.2%
if 2.7999999999999999e132 < y Initial program 99.5%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6493.1
Applied rewrites93.1%
Taylor expanded in z around inf
Applied rewrites69.6%
Taylor expanded in z around 0
Applied rewrites83.0%
(FPCore (x y z) :precision binary64 (- (+ (* 1.0 x) y) z))
double code(double x, double y, double z) {
return ((1.0 * x) + y) - z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((1.0d0 * x) + y) - z
end function
public static double code(double x, double y, double z) {
return ((1.0 * x) + y) - z;
}
def code(x, y, z): return ((1.0 * x) + y) - z
function code(x, y, z) return Float64(Float64(Float64(1.0 * x) + y) - z) end
function tmp = code(x, y, z) tmp = ((1.0 * x) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(1.0 * x), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(1 \cdot x + y\right) - z
\end{array}
Initial program 99.8%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
flip3-+N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
lower-/.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
*-commutativeN/A
metadata-evalN/A
distribute-lft-inN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
neg-mul-1N/A
lower-*.f64N/A
Applied rewrites90.7%
Taylor expanded in x around inf
Applied rewrites56.9%
(FPCore (x y z) :precision binary64 (- z))
double code(double x, double y, double z) {
return -z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -z
end function
public static double code(double x, double y, double z) {
return -z;
}
def code(x, y, z): return -z
function code(x, y, z) return Float64(-z) end
function tmp = code(x, y, z) tmp = -z; end
code[x_, y_, z_] := (-z)
\begin{array}{l}
\\
-z
\end{array}
Initial program 99.8%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6430.5
Applied rewrites30.5%
(FPCore (x y z) :precision binary64 (- (- (+ y x) z) (* (+ y 0.5) (log y))))
double code(double x, double y, double z) {
return ((y + x) - z) - ((y + 0.5) * log(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((y + x) - z) - ((y + 0.5d0) * log(y))
end function
public static double code(double x, double y, double z) {
return ((y + x) - z) - ((y + 0.5) * Math.log(y));
}
def code(x, y, z): return ((y + x) - z) - ((y + 0.5) * math.log(y))
function code(x, y, z) return Float64(Float64(Float64(y + x) - z) - Float64(Float64(y + 0.5) * log(y))) end
function tmp = code(x, y, z) tmp = ((y + x) - z) - ((y + 0.5) * log(y)); end
code[x_, y_, z_] := N[(N[(N[(y + x), $MachinePrecision] - z), $MachinePrecision] - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(y + x\right) - z\right) - \left(y + 0.5\right) \cdot \log y
\end{array}
herbie shell --seed 2024315
(FPCore (x y z)
:name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (- (- (+ y x) z) (* (+ y 1/2) (log y))))
(- (+ (- x (* (+ y 0.5) (log y))) y) z))