
(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 10 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 (- 1.0 (log y)))) (* (log y) 0.5)) z))
double code(double x, double y, double z) {
return ((x + (y * (1.0 - log(y)))) - (log(y) * 0.5)) - 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 * (1.0d0 - log(y)))) - (log(y) * 0.5d0)) - z
end function
public static double code(double x, double y, double z) {
return ((x + (y * (1.0 - Math.log(y)))) - (Math.log(y) * 0.5)) - z;
}
def code(x, y, z): return ((x + (y * (1.0 - math.log(y)))) - (math.log(y) * 0.5)) - z
function code(x, y, z) return Float64(Float64(Float64(x + Float64(y * Float64(1.0 - log(y)))) - Float64(log(y) * 0.5)) - z) end
function tmp = code(x, y, z) tmp = ((x + (y * (1.0 - log(y)))) - (log(y) * 0.5)) - z; end
code[x_, y_, z_] := N[(N[(N[(x + N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + y \cdot \left(1 - \log y\right)\right) - \log y \cdot 0.5\right) - z
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (fma (log y) (- -0.5 y) (+ y (- x z))))
double code(double x, double y, double z) {
return fma(log(y), (-0.5 - y), (y + (x - z)));
}
function code(x, y, z) return fma(log(y), Float64(-0.5 - y), Float64(y + Float64(x - z))) end
code[x_, y_, z_] := N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + N[(y + N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, -0.5 - y, y + \left(x - z\right)\right)
\end{array}
Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
+-commutative99.9%
associate-+l+99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-def99.9%
neg-sub099.9%
+-commutative99.9%
associate--r+99.9%
metadata-eval99.9%
associate-+r-99.9%
+-commutative99.9%
associate-+r-99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* y (- 1.0 (log y))) z)) (t_1 (+ y (* (log y) (- -0.5 y)))))
(if (<= x -16500000.0)
(- x z)
(if (<= x -1.55e-117)
t_1
(if (<= x -2.05e-197)
t_0
(if (<= x -5.8e-307)
t_1
(if (<= x 9e-280)
t_0
(if (<= x 8.5e-182) t_1 (if (<= x 2e+85) t_0 (- x z))))))))))
double code(double x, double y, double z) {
double t_0 = (y * (1.0 - log(y))) - z;
double t_1 = y + (log(y) * (-0.5 - y));
double tmp;
if (x <= -16500000.0) {
tmp = x - z;
} else if (x <= -1.55e-117) {
tmp = t_1;
} else if (x <= -2.05e-197) {
tmp = t_0;
} else if (x <= -5.8e-307) {
tmp = t_1;
} else if (x <= 9e-280) {
tmp = t_0;
} else if (x <= 8.5e-182) {
tmp = t_1;
} else if (x <= 2e+85) {
tmp = t_0;
} else {
tmp = x - z;
}
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) :: t_1
real(8) :: tmp
t_0 = (y * (1.0d0 - log(y))) - z
t_1 = y + (log(y) * ((-0.5d0) - y))
if (x <= (-16500000.0d0)) then
tmp = x - z
else if (x <= (-1.55d-117)) then
tmp = t_1
else if (x <= (-2.05d-197)) then
tmp = t_0
else if (x <= (-5.8d-307)) then
tmp = t_1
else if (x <= 9d-280) then
tmp = t_0
else if (x <= 8.5d-182) then
tmp = t_1
else if (x <= 2d+85) then
tmp = t_0
else
tmp = x - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y * (1.0 - Math.log(y))) - z;
double t_1 = y + (Math.log(y) * (-0.5 - y));
double tmp;
if (x <= -16500000.0) {
tmp = x - z;
} else if (x <= -1.55e-117) {
tmp = t_1;
} else if (x <= -2.05e-197) {
tmp = t_0;
} else if (x <= -5.8e-307) {
tmp = t_1;
} else if (x <= 9e-280) {
tmp = t_0;
} else if (x <= 8.5e-182) {
tmp = t_1;
} else if (x <= 2e+85) {
tmp = t_0;
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): t_0 = (y * (1.0 - math.log(y))) - z t_1 = y + (math.log(y) * (-0.5 - y)) tmp = 0 if x <= -16500000.0: tmp = x - z elif x <= -1.55e-117: tmp = t_1 elif x <= -2.05e-197: tmp = t_0 elif x <= -5.8e-307: tmp = t_1 elif x <= 9e-280: tmp = t_0 elif x <= 8.5e-182: tmp = t_1 elif x <= 2e+85: tmp = t_0 else: tmp = x - z return tmp
function code(x, y, z) t_0 = Float64(Float64(y * Float64(1.0 - log(y))) - z) t_1 = Float64(y + Float64(log(y) * Float64(-0.5 - y))) tmp = 0.0 if (x <= -16500000.0) tmp = Float64(x - z); elseif (x <= -1.55e-117) tmp = t_1; elseif (x <= -2.05e-197) tmp = t_0; elseif (x <= -5.8e-307) tmp = t_1; elseif (x <= 9e-280) tmp = t_0; elseif (x <= 8.5e-182) tmp = t_1; elseif (x <= 2e+85) tmp = t_0; else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y * (1.0 - log(y))) - z; t_1 = y + (log(y) * (-0.5 - y)); tmp = 0.0; if (x <= -16500000.0) tmp = x - z; elseif (x <= -1.55e-117) tmp = t_1; elseif (x <= -2.05e-197) tmp = t_0; elseif (x <= -5.8e-307) tmp = t_1; elseif (x <= 9e-280) tmp = t_0; elseif (x <= 8.5e-182) tmp = t_1; elseif (x <= 2e+85) tmp = t_0; else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(y + N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -16500000.0], N[(x - z), $MachinePrecision], If[LessEqual[x, -1.55e-117], t$95$1, If[LessEqual[x, -2.05e-197], t$95$0, If[LessEqual[x, -5.8e-307], t$95$1, If[LessEqual[x, 9e-280], t$95$0, If[LessEqual[x, 8.5e-182], t$95$1, If[LessEqual[x, 2e+85], t$95$0, N[(x - z), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - \log y\right) - z\\
t_1 := y + \log y \cdot \left(-0.5 - y\right)\\
\mathbf{if}\;x \leq -16500000:\\
\;\;\;\;x - z\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-117}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -2.05 \cdot 10^{-197}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -5.8 \cdot 10^{-307}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-280}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{-182}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+85}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if x < -1.65e7 or 2e85 < x Initial program 100.0%
Taylor expanded in x around inf 88.7%
if -1.65e7 < x < -1.55000000000000005e-117 or -2.05e-197 < x < -5.8000000000000001e-307 or 8.9999999999999991e-280 < x < 8.5000000000000001e-182Initial program 99.7%
associate--l+99.7%
sub-neg99.7%
+-commutative99.7%
associate-+l+99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
fma-def99.8%
neg-sub099.8%
+-commutative99.8%
associate--r+99.8%
metadata-eval99.8%
associate-+r-99.8%
+-commutative99.8%
associate-+r-99.8%
Simplified99.8%
Taylor expanded in y around inf 80.6%
fma-udef80.5%
Applied egg-rr80.5%
if -1.55000000000000005e-117 < x < -2.05e-197 or -5.8000000000000001e-307 < x < 8.9999999999999991e-280 or 8.5000000000000001e-182 < x < 2e85Initial program 99.9%
Taylor expanded in y around inf 86.1%
*-commutative86.1%
log-rec86.1%
cancel-sign-sub86.1%
*-commutative86.1%
mul-1-neg86.1%
sub-neg86.1%
Simplified86.1%
Final simplification86.0%
(FPCore (x y z)
:precision binary64
(if (<= x -18500000.0)
(- x z)
(if (<= x 3e-164)
(+ y (* (log y) (- -0.5 y)))
(if (<= x 125.0) (- (* (log y) -0.5) z) (- x z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -18500000.0) {
tmp = x - z;
} else if (x <= 3e-164) {
tmp = y + (log(y) * (-0.5 - y));
} else if (x <= 125.0) {
tmp = (log(y) * -0.5) - z;
} else {
tmp = x - z;
}
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) :: tmp
if (x <= (-18500000.0d0)) then
tmp = x - z
else if (x <= 3d-164) then
tmp = y + (log(y) * ((-0.5d0) - y))
else if (x <= 125.0d0) then
tmp = (log(y) * (-0.5d0)) - z
else
tmp = x - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -18500000.0) {
tmp = x - z;
} else if (x <= 3e-164) {
tmp = y + (Math.log(y) * (-0.5 - y));
} else if (x <= 125.0) {
tmp = (Math.log(y) * -0.5) - z;
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -18500000.0: tmp = x - z elif x <= 3e-164: tmp = y + (math.log(y) * (-0.5 - y)) elif x <= 125.0: tmp = (math.log(y) * -0.5) - z else: tmp = x - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -18500000.0) tmp = Float64(x - z); elseif (x <= 3e-164) tmp = Float64(y + Float64(log(y) * Float64(-0.5 - y))); elseif (x <= 125.0) tmp = Float64(Float64(log(y) * -0.5) - z); else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -18500000.0) tmp = x - z; elseif (x <= 3e-164) tmp = y + (log(y) * (-0.5 - y)); elseif (x <= 125.0) tmp = (log(y) * -0.5) - z; else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -18500000.0], N[(x - z), $MachinePrecision], If[LessEqual[x, 3e-164], N[(y + N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 125.0], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], N[(x - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -18500000:\\
\;\;\;\;x - z\\
\mathbf{elif}\;x \leq 3 \cdot 10^{-164}:\\
\;\;\;\;y + \log y \cdot \left(-0.5 - y\right)\\
\mathbf{elif}\;x \leq 125:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if x < -1.85e7 or 125 < x Initial program 100.0%
Taylor expanded in x around inf 87.0%
if -1.85e7 < x < 3.0000000000000001e-164Initial program 99.8%
associate--l+99.8%
sub-neg99.8%
+-commutative99.8%
associate-+l+99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
fma-def99.9%
neg-sub099.9%
+-commutative99.9%
associate--r+99.9%
metadata-eval99.9%
associate-+r-99.9%
+-commutative99.9%
associate-+r-99.9%
Simplified99.9%
Taylor expanded in y around inf 68.8%
fma-udef68.8%
Applied egg-rr68.8%
if 3.0000000000000001e-164 < x < 125Initial program 99.7%
Taylor expanded in y around 0 71.2%
Taylor expanded in x around 0 71.2%
*-commutative71.2%
Simplified71.2%
Final simplification78.5%
(FPCore (x y z) :precision binary64 (if (<= y 0.00315) (- (- x (* (log y) 0.5)) z) (- (+ y (- x (* y (log y)))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.00315) {
tmp = (x - (log(y) * 0.5)) - z;
} else {
tmp = (y + (x - (y * log(y)))) - z;
}
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) :: tmp
if (y <= 0.00315d0) then
tmp = (x - (log(y) * 0.5d0)) - z
else
tmp = (y + (x - (y * log(y)))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 0.00315) {
tmp = (x - (Math.log(y) * 0.5)) - z;
} else {
tmp = (y + (x - (y * Math.log(y)))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 0.00315: tmp = (x - (math.log(y) * 0.5)) - z else: tmp = (y + (x - (y * math.log(y)))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 0.00315) tmp = Float64(Float64(x - Float64(log(y) * 0.5)) - z); else tmp = Float64(Float64(y + Float64(x - Float64(y * log(y)))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 0.00315) tmp = (x - (log(y) * 0.5)) - z; else tmp = (y + (x - (y * log(y)))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 0.00315], N[(N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(y + N[(x - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.00315:\\
\;\;\;\;\left(x - \log y \cdot 0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(y + \left(x - y \cdot \log y\right)\right) - z\\
\end{array}
\end{array}
if y < 0.00315Initial program 100.0%
Taylor expanded in y around 0 99.0%
if 0.00315 < y Initial program 99.8%
Taylor expanded in y around inf 99.8%
mul-1-neg99.8%
distribute-rgt-neg-in99.8%
log-rec99.8%
remove-double-neg99.8%
Simplified99.8%
Final simplification99.3%
(FPCore (x y z) :precision binary64 (- (+ y (- x (* (log y) (+ y 0.5)))) z))
double code(double x, double y, double z) {
return (y + (x - (log(y) * (y + 0.5)))) - z;
}
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 - (log(y) * (y + 0.5d0)))) - z
end function
public static double code(double x, double y, double z) {
return (y + (x - (Math.log(y) * (y + 0.5)))) - z;
}
def code(x, y, z): return (y + (x - (math.log(y) * (y + 0.5)))) - z
function code(x, y, z) return Float64(Float64(y + Float64(x - Float64(log(y) * Float64(y + 0.5)))) - z) end
function tmp = code(x, y, z) tmp = (y + (x - (log(y) * (y + 0.5)))) - z; end
code[x_, y_, z_] := N[(N[(y + N[(x - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(y + \left(x - \log y \cdot \left(y + 0.5\right)\right)\right) - z
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -118.0) (not (<= x 125.0))) (- x z) (- (* (log y) -0.5) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -118.0) || !(x <= 125.0)) {
tmp = x - z;
} else {
tmp = (log(y) * -0.5) - z;
}
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) :: tmp
if ((x <= (-118.0d0)) .or. (.not. (x <= 125.0d0))) then
tmp = x - z
else
tmp = (log(y) * (-0.5d0)) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -118.0) || !(x <= 125.0)) {
tmp = x - z;
} else {
tmp = (Math.log(y) * -0.5) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -118.0) or not (x <= 125.0): tmp = x - z else: tmp = (math.log(y) * -0.5) - z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -118.0) || !(x <= 125.0)) tmp = Float64(x - z); else tmp = Float64(Float64(log(y) * -0.5) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -118.0) || ~((x <= 125.0))) tmp = x - z; else tmp = (log(y) * -0.5) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -118.0], N[Not[LessEqual[x, 125.0]], $MachinePrecision]], N[(x - z), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -118 \lor \neg \left(x \leq 125\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\end{array}
\end{array}
if x < -118 or 125 < x Initial program 100.0%
Taylor expanded in x around inf 86.4%
if -118 < x < 125Initial program 99.8%
Taylor expanded in y around 0 66.5%
Taylor expanded in x around 0 65.9%
*-commutative65.9%
Simplified65.9%
Final simplification76.6%
(FPCore (x y z) :precision binary64 (if (<= y 1.85e+62) (- (- x (* (log y) 0.5)) z) (- (* y (- 1.0 (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.85e+62) {
tmp = (x - (log(y) * 0.5)) - z;
} else {
tmp = (y * (1.0 - log(y))) - z;
}
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) :: tmp
if (y <= 1.85d+62) then
tmp = (x - (log(y) * 0.5d0)) - z
else
tmp = (y * (1.0d0 - log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.85e+62) {
tmp = (x - (Math.log(y) * 0.5)) - z;
} else {
tmp = (y * (1.0 - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.85e+62: tmp = (x - (math.log(y) * 0.5)) - z else: tmp = (y * (1.0 - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.85e+62) tmp = Float64(Float64(x - Float64(log(y) * 0.5)) - z); else tmp = Float64(Float64(y * Float64(1.0 - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.85e+62) tmp = (x - (log(y) * 0.5)) - z; else tmp = (y * (1.0 - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.85e+62], N[(N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.85 \cdot 10^{+62}:\\
\;\;\;\;\left(x - \log y \cdot 0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right) - z\\
\end{array}
\end{array}
if y < 1.85000000000000007e62Initial program 99.9%
Taylor expanded in y around 0 94.8%
if 1.85000000000000007e62 < y Initial program 99.7%
Taylor expanded in y around inf 80.5%
*-commutative80.5%
log-rec80.5%
cancel-sign-sub80.5%
*-commutative80.5%
mul-1-neg80.5%
sub-neg80.5%
Simplified80.5%
Final simplification90.0%
(FPCore (x y z) :precision binary64 (- x z))
double code(double x, double y, double z) {
return x - 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 - z
end function
public static double code(double x, double y, double z) {
return x - z;
}
def code(x, y, z): return x - z
function code(x, y, z) return Float64(x - z) end
function tmp = code(x, y, z) tmp = x - z; end
code[x_, y_, z_] := N[(x - z), $MachinePrecision]
\begin{array}{l}
\\
x - z
\end{array}
Initial program 99.9%
Taylor expanded in x around inf 62.7%
Final simplification62.7%
(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.9%
Taylor expanded in z around inf 30.3%
neg-mul-130.3%
Simplified30.3%
Final simplification30.3%
(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 2023192
(FPCore (x y z)
:name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(- (- (+ y x) z) (* (+ y 0.5) (log y)))
(- (+ (- x (* (+ y 0.5) (log y))) y) z))