
(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 (- (fma (log y) (- -0.5 y) y) z)))
double code(double x, double y, double z) {
return x + (fma(log(y), (-0.5 - y), y) - z);
}
function code(x, y, z) return Float64(x + Float64(fma(log(y), Float64(-0.5 - y), y) - z)) end
code[x_, y_, z_] := N[(x + N[(N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\mathsf{fma}\left(\log y, -0.5 - y, y\right) - z\right)
\end{array}
Initial program 99.8%
associate--l+99.8%
sub-neg99.8%
associate-+l+99.8%
associate-+r-99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
fma-def99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (- 1.0 (log y)))) (t_1 (- t_0 z)) (t_2 (+ x t_0)))
(if (<= x -2100.0)
t_2
(if (<= x 3.2e-241)
t_1
(if (<= x 1.5e-146)
(- y (* (log y) (+ y 0.5)))
(if (<= x 1.2e+60) t_1 t_2))))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - log(y));
double t_1 = t_0 - z;
double t_2 = x + t_0;
double tmp;
if (x <= -2100.0) {
tmp = t_2;
} else if (x <= 3.2e-241) {
tmp = t_1;
} else if (x <= 1.5e-146) {
tmp = y - (log(y) * (y + 0.5));
} else if (x <= 1.2e+60) {
tmp = t_1;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_0 = y * (1.0d0 - log(y))
t_1 = t_0 - z
t_2 = x + t_0
if (x <= (-2100.0d0)) then
tmp = t_2
else if (x <= 3.2d-241) then
tmp = t_1
else if (x <= 1.5d-146) then
tmp = y - (log(y) * (y + 0.5d0))
else if (x <= 1.2d+60) then
tmp = t_1
else
tmp = t_2
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));
double t_1 = t_0 - z;
double t_2 = x + t_0;
double tmp;
if (x <= -2100.0) {
tmp = t_2;
} else if (x <= 3.2e-241) {
tmp = t_1;
} else if (x <= 1.5e-146) {
tmp = y - (Math.log(y) * (y + 0.5));
} else if (x <= 1.2e+60) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 - math.log(y)) t_1 = t_0 - z t_2 = x + t_0 tmp = 0 if x <= -2100.0: tmp = t_2 elif x <= 3.2e-241: tmp = t_1 elif x <= 1.5e-146: tmp = y - (math.log(y) * (y + 0.5)) elif x <= 1.2e+60: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - log(y))) t_1 = Float64(t_0 - z) t_2 = Float64(x + t_0) tmp = 0.0 if (x <= -2100.0) tmp = t_2; elseif (x <= 3.2e-241) tmp = t_1; elseif (x <= 1.5e-146) tmp = Float64(y - Float64(log(y) * Float64(y + 0.5))); elseif (x <= 1.2e+60) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 - log(y)); t_1 = t_0 - z; t_2 = x + t_0; tmp = 0.0; if (x <= -2100.0) tmp = t_2; elseif (x <= 3.2e-241) tmp = t_1; elseif (x <= 1.5e-146) tmp = y - (log(y) * (y + 0.5)); elseif (x <= 1.2e+60) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - z), $MachinePrecision]}, Block[{t$95$2 = N[(x + t$95$0), $MachinePrecision]}, If[LessEqual[x, -2100.0], t$95$2, If[LessEqual[x, 3.2e-241], t$95$1, If[LessEqual[x, 1.5e-146], N[(y - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.2e+60], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - \log y\right)\\
t_1 := t_0 - z\\
t_2 := x + t_0\\
\mathbf{if}\;x \leq -2100:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-241}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{-146}:\\
\;\;\;\;y - \log y \cdot \left(y + 0.5\right)\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{+60}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if x < -2100 or 1.2e60 < x Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
associate-+l+99.9%
associate-+r-99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-def99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 97.6%
log-rec97.6%
sub-neg97.6%
Simplified97.6%
Taylor expanded in z around 0 85.9%
if -2100 < x < 3.2e-241 or 1.50000000000000009e-146 < x < 1.2e60Initial program 99.7%
associate--l+99.7%
sub-neg99.7%
associate-+l+99.7%
associate-+r-99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
fma-def99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 81.0%
log-rec81.0%
sub-neg81.0%
Simplified81.0%
Taylor expanded in x around 0 79.3%
if 3.2e-241 < x < 1.50000000000000009e-146Initial program 99.7%
associate--l+99.8%
sub-neg99.8%
associate-+l+99.8%
associate-+r-99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
fma-def99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 99.7%
associate-*r*99.7%
neg-mul-199.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
associate--r+99.7%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around 0 87.5%
+-commutative87.5%
Simplified87.5%
Final simplification82.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (- 1.0 (log y)))))
(if (<= y 1.55e+19)
(- (+ x (* (log y) -0.5)) z)
(if (or (<= y 6.8e+109) (not (<= y 2.6e+196))) (+ x t_0) (- t_0 z)))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - log(y));
double tmp;
if (y <= 1.55e+19) {
tmp = (x + (log(y) * -0.5)) - z;
} else if ((y <= 6.8e+109) || !(y <= 2.6e+196)) {
tmp = x + t_0;
} else {
tmp = t_0 - 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) :: tmp
t_0 = y * (1.0d0 - log(y))
if (y <= 1.55d+19) then
tmp = (x + (log(y) * (-0.5d0))) - z
else if ((y <= 6.8d+109) .or. (.not. (y <= 2.6d+196))) then
tmp = x + t_0
else
tmp = t_0 - 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));
double tmp;
if (y <= 1.55e+19) {
tmp = (x + (Math.log(y) * -0.5)) - z;
} else if ((y <= 6.8e+109) || !(y <= 2.6e+196)) {
tmp = x + t_0;
} else {
tmp = t_0 - z;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 - math.log(y)) tmp = 0 if y <= 1.55e+19: tmp = (x + (math.log(y) * -0.5)) - z elif (y <= 6.8e+109) or not (y <= 2.6e+196): tmp = x + t_0 else: tmp = t_0 - z return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - log(y))) tmp = 0.0 if (y <= 1.55e+19) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z); elseif ((y <= 6.8e+109) || !(y <= 2.6e+196)) tmp = Float64(x + t_0); else tmp = Float64(t_0 - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 - log(y)); tmp = 0.0; if (y <= 1.55e+19) tmp = (x + (log(y) * -0.5)) - z; elseif ((y <= 6.8e+109) || ~((y <= 2.6e+196))) tmp = x + t_0; else tmp = t_0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1.55e+19], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[Or[LessEqual[y, 6.8e+109], N[Not[LessEqual[y, 2.6e+196]], $MachinePrecision]], N[(x + t$95$0), $MachinePrecision], N[(t$95$0 - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - \log y\right)\\
\mathbf{if}\;y \leq 1.55 \cdot 10^{+19}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{+109} \lor \neg \left(y \leq 2.6 \cdot 10^{+196}\right):\\
\;\;\;\;x + t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 - z\\
\end{array}
\end{array}
if y < 1.55e19Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
associate-+l+99.9%
associate-+r-99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-def100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 97.4%
if 1.55e19 < y < 6.80000000000000013e109 or 2.60000000000000012e196 < y Initial program 99.6%
associate--l+99.6%
sub-neg99.6%
associate-+l+99.6%
associate-+r-99.6%
*-commutative99.6%
distribute-rgt-neg-in99.6%
fma-def99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 99.7%
log-rec99.7%
sub-neg99.7%
Simplified99.7%
Taylor expanded in z around 0 91.5%
if 6.80000000000000013e109 < y < 2.60000000000000012e196Initial program 99.6%
associate--l+99.6%
sub-neg99.6%
associate-+l+99.6%
associate-+r-99.6%
*-commutative99.6%
distribute-rgt-neg-in99.6%
fma-def99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 99.8%
log-rec99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in x around 0 85.2%
Final simplification93.8%
(FPCore (x y z) :precision binary64 (if (or (<= y 5.8e+16) (and (not (<= y 1.05e+38)) (<= y 1.1e+112))) (- x z) (* y (- 1.0 (log y)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= 5.8e+16) || (!(y <= 1.05e+38) && (y <= 1.1e+112))) {
tmp = x - z;
} else {
tmp = y * (1.0 - 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) :: tmp
if ((y <= 5.8d+16) .or. (.not. (y <= 1.05d+38)) .and. (y <= 1.1d+112)) then
tmp = x - z
else
tmp = y * (1.0d0 - log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= 5.8e+16) || (!(y <= 1.05e+38) && (y <= 1.1e+112))) {
tmp = x - z;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= 5.8e+16) or (not (y <= 1.05e+38) and (y <= 1.1e+112)): tmp = x - z else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= 5.8e+16) || (!(y <= 1.05e+38) && (y <= 1.1e+112))) tmp = Float64(x - z); else tmp = Float64(y * Float64(1.0 - log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= 5.8e+16) || (~((y <= 1.05e+38)) && (y <= 1.1e+112))) tmp = x - z; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, 5.8e+16], And[N[Not[LessEqual[y, 1.05e+38]], $MachinePrecision], LessEqual[y, 1.1e+112]]], N[(x - z), $MachinePrecision], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.8 \cdot 10^{+16} \lor \neg \left(y \leq 1.05 \cdot 10^{+38}\right) \land y \leq 1.1 \cdot 10^{+112}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 5.8e16 or 1.05e38 < y < 1.1e112Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
associate-+l+99.9%
associate-+r-99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-def100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 79.8%
log-rec79.8%
sub-neg79.8%
Simplified79.8%
Taylor expanded in y around 0 71.9%
if 5.8e16 < y < 1.05e38 or 1.1e112 < y Initial program 99.5%
associate--l+99.5%
sub-neg99.5%
associate-+l+99.5%
associate-+r-99.5%
*-commutative99.5%
distribute-rgt-neg-in99.5%
fma-def99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 89.2%
associate-*r*89.2%
neg-mul-189.2%
+-commutative89.2%
cancel-sign-sub-inv89.2%
associate--r+89.2%
fma-def89.2%
Simplified89.2%
Taylor expanded in z around 0 78.3%
+-commutative78.3%
Simplified78.3%
Taylor expanded in y around inf 78.4%
mul-1-neg78.4%
log-rec78.4%
remove-double-neg78.4%
Simplified78.4%
Final simplification74.1%
(FPCore (x y z) :precision binary64 (if (<= y 0.28) (- (+ x (* (log y) -0.5)) z) (+ x (- (* y (- 1.0 (log y))) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.28) {
tmp = (x + (log(y) * -0.5)) - z;
} else {
tmp = x + ((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 <= 0.28d0) then
tmp = (x + (log(y) * (-0.5d0))) - z
else
tmp = x + ((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 <= 0.28) {
tmp = (x + (Math.log(y) * -0.5)) - z;
} else {
tmp = x + ((y * (1.0 - Math.log(y))) - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 0.28: tmp = (x + (math.log(y) * -0.5)) - z else: tmp = x + ((y * (1.0 - math.log(y))) - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 0.28) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z); else tmp = Float64(x + 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 <= 0.28) tmp = (x + (log(y) * -0.5)) - z; else tmp = x + ((y * (1.0 - log(y))) - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 0.28], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(x + N[(N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.28:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;x + \left(y \cdot \left(1 - \log y\right) - z\right)\\
\end{array}
\end{array}
if y < 0.28000000000000003Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
associate-+l+99.9%
associate-+r-99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-def100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.3%
if 0.28000000000000003 < y Initial program 99.6%
associate--l+99.6%
sub-neg99.6%
associate-+l+99.6%
associate-+r-99.6%
*-commutative99.6%
distribute-rgt-neg-in99.6%
fma-def99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 98.7%
log-rec98.7%
sub-neg98.7%
Simplified98.7%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (<= y 5.4e+15) (- x z) (+ x (* y (- 1.0 (log y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 5.4e+15) {
tmp = x - z;
} else {
tmp = x + (y * (1.0 - 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) :: tmp
if (y <= 5.4d+15) then
tmp = x - z
else
tmp = x + (y * (1.0d0 - log(y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 5.4e+15) {
tmp = x - z;
} else {
tmp = x + (y * (1.0 - Math.log(y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5.4e+15: tmp = x - z else: tmp = x + (y * (1.0 - math.log(y))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5.4e+15) tmp = Float64(x - z); else tmp = Float64(x + Float64(y * Float64(1.0 - log(y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 5.4e+15) tmp = x - z; else tmp = x + (y * (1.0 - log(y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5.4e+15], N[(x - z), $MachinePrecision], N[(x + N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.4 \cdot 10^{+15}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 5.4e15Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
associate-+l+99.9%
associate-+r-99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-def100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 74.9%
log-rec74.9%
sub-neg74.9%
Simplified74.9%
Taylor expanded in y around 0 74.2%
if 5.4e15 < y Initial program 99.6%
associate--l+99.6%
sub-neg99.6%
associate-+l+99.6%
associate-+r-99.6%
*-commutative99.6%
distribute-rgt-neg-in99.6%
fma-def99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 99.7%
log-rec99.7%
sub-neg99.7%
Simplified99.7%
Taylor expanded in z around 0 85.7%
Final simplification79.6%
(FPCore (x y z) :precision binary64 (+ (- x (* (log y) (+ y 0.5))) (- y z)))
double code(double x, double y, double z) {
return (x - (log(y) * (y + 0.5))) + (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 - (log(y) * (y + 0.5d0))) + (y - z)
end function
public static double code(double x, double y, double z) {
return (x - (Math.log(y) * (y + 0.5))) + (y - z);
}
def code(x, y, z): return (x - (math.log(y) * (y + 0.5))) + (y - z)
function code(x, y, z) return Float64(Float64(x - Float64(log(y) * Float64(y + 0.5))) + Float64(y - z)) end
function tmp = code(x, y, z) tmp = (x - (log(y) * (y + 0.5))) + (y - z); end
code[x_, y_, z_] := N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x - \log y \cdot \left(y + 0.5\right)\right) + \left(y - z\right)
\end{array}
Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (<= x -1.8e-14) x (if (<= x 2.15e+60) (- z) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.8e-14) {
tmp = x;
} else if (x <= 2.15e+60) {
tmp = -z;
} else {
tmp = x;
}
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 <= (-1.8d-14)) then
tmp = x
else if (x <= 2.15d+60) then
tmp = -z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.8e-14) {
tmp = x;
} else if (x <= 2.15e+60) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.8e-14: tmp = x elif x <= 2.15e+60: tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.8e-14) tmp = x; elseif (x <= 2.15e+60) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.8e-14) tmp = x; elseif (x <= 2.15e+60) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.8e-14], x, If[LessEqual[x, 2.15e+60], (-z), x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.8 \cdot 10^{-14}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.15 \cdot 10^{+60}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.7999999999999999e-14 or 2.14999999999999986e60 < x Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
associate-+l+99.9%
associate-+r-99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-def99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 61.9%
if -1.7999999999999999e-14 < x < 2.14999999999999986e60Initial program 99.7%
associate--l+99.7%
sub-neg99.7%
associate-+l+99.7%
associate-+r-99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
fma-def99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 37.5%
neg-mul-137.5%
Simplified37.5%
Final simplification48.7%
(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.8%
associate--l+99.8%
sub-neg99.8%
associate-+l+99.8%
associate-+r-99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
fma-def99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 86.6%
log-rec86.6%
sub-neg86.6%
Simplified86.6%
Taylor expanded in y around 0 54.5%
Final simplification54.5%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.8%
associate--l+99.8%
sub-neg99.8%
associate-+l+99.8%
associate-+r-99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
fma-def99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 30.5%
Final simplification30.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 2024020
(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))