
(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 (- (* (log y) -0.5) z)))
(if (<= y 1.3e-147)
t_0
(if (<= y 9.4e-51)
(- x z)
(if (<= y 5.8e-11)
t_0
(if (<= y 8.4e+102) (- x z) (- (* y (- 1.0 (log y))) z)))))))
double code(double x, double y, double z) {
double t_0 = (log(y) * -0.5) - z;
double tmp;
if (y <= 1.3e-147) {
tmp = t_0;
} else if (y <= 9.4e-51) {
tmp = x - z;
} else if (y <= 5.8e-11) {
tmp = t_0;
} else if (y <= 8.4e+102) {
tmp = x - 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) :: t_0
real(8) :: tmp
t_0 = (log(y) * (-0.5d0)) - z
if (y <= 1.3d-147) then
tmp = t_0
else if (y <= 9.4d-51) then
tmp = x - z
else if (y <= 5.8d-11) then
tmp = t_0
else if (y <= 8.4d+102) then
tmp = x - 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 t_0 = (Math.log(y) * -0.5) - z;
double tmp;
if (y <= 1.3e-147) {
tmp = t_0;
} else if (y <= 9.4e-51) {
tmp = x - z;
} else if (y <= 5.8e-11) {
tmp = t_0;
} else if (y <= 8.4e+102) {
tmp = x - z;
} else {
tmp = (y * (1.0 - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): t_0 = (math.log(y) * -0.5) - z tmp = 0 if y <= 1.3e-147: tmp = t_0 elif y <= 9.4e-51: tmp = x - z elif y <= 5.8e-11: tmp = t_0 elif y <= 8.4e+102: tmp = x - z else: tmp = (y * (1.0 - math.log(y))) - z return tmp
function code(x, y, z) t_0 = Float64(Float64(log(y) * -0.5) - z) tmp = 0.0 if (y <= 1.3e-147) tmp = t_0; elseif (y <= 9.4e-51) tmp = Float64(x - z); elseif (y <= 5.8e-11) tmp = t_0; elseif (y <= 8.4e+102) tmp = Float64(x - z); else tmp = Float64(Float64(y * Float64(1.0 - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (log(y) * -0.5) - z; tmp = 0.0; if (y <= 1.3e-147) tmp = t_0; elseif (y <= 9.4e-51) tmp = x - z; elseif (y <= 5.8e-11) tmp = t_0; elseif (y <= 8.4e+102) tmp = x - z; else tmp = (y * (1.0 - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[y, 1.3e-147], t$95$0, If[LessEqual[y, 9.4e-51], N[(x - z), $MachinePrecision], If[LessEqual[y, 5.8e-11], t$95$0, If[LessEqual[y, 8.4e+102], N[(x - z), $MachinePrecision], N[(N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log y \cdot -0.5 - z\\
\mathbf{if}\;y \leq 1.3 \cdot 10^{-147}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 9.4 \cdot 10^{-51}:\\
\;\;\;\;x - z\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{-11}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 8.4 \cdot 10^{+102}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right) - z\\
\end{array}
\end{array}
if y < 1.2999999999999999e-147 or 9.3999999999999995e-51 < y < 5.8e-11Initial 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 0 74.2%
associate-*r*74.2%
neg-mul-174.2%
+-commutative74.2%
cancel-sign-sub-inv74.2%
Simplified74.2%
Taylor expanded in y around 0 73.9%
*-commutative73.9%
Simplified73.9%
if 1.2999999999999999e-147 < y < 9.3999999999999995e-51 or 5.8e-11 < y < 8.40000000000000006e102Initial 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 95.8%
log-rec95.8%
sub-neg95.8%
Simplified95.8%
Taylor expanded in y around 0 80.1%
neg-mul-180.1%
Simplified80.1%
if 8.40000000000000006e102 < y Initial program 99.6%
Taylor expanded in y around inf 89.0%
*-commutative89.0%
log-rec89.0%
distribute-lft-neg-in89.0%
distribute-rgt-neg-in89.0%
Simplified89.0%
Taylor expanded in y around 0 89.1%
neg-mul-189.1%
sub-neg89.1%
Simplified89.1%
Final simplification81.3%
(FPCore (x y z)
:precision binary64
(if (<= x -18000.0)
(- x z)
(if (<= x -2.2e-56)
(- (* (log y) -0.5) z)
(if (<= x 8.8e-12) (- y (* (log y) (+ y 0.5))) (- x z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -18000.0) {
tmp = x - z;
} else if (x <= -2.2e-56) {
tmp = (log(y) * -0.5) - z;
} else if (x <= 8.8e-12) {
tmp = y - (log(y) * (y + 0.5));
} 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 <= (-18000.0d0)) then
tmp = x - z
else if (x <= (-2.2d-56)) then
tmp = (log(y) * (-0.5d0)) - z
else if (x <= 8.8d-12) then
tmp = y - (log(y) * (y + 0.5d0))
else
tmp = x - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -18000.0) {
tmp = x - z;
} else if (x <= -2.2e-56) {
tmp = (Math.log(y) * -0.5) - z;
} else if (x <= 8.8e-12) {
tmp = y - (Math.log(y) * (y + 0.5));
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -18000.0: tmp = x - z elif x <= -2.2e-56: tmp = (math.log(y) * -0.5) - z elif x <= 8.8e-12: tmp = y - (math.log(y) * (y + 0.5)) else: tmp = x - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -18000.0) tmp = Float64(x - z); elseif (x <= -2.2e-56) tmp = Float64(Float64(log(y) * -0.5) - z); elseif (x <= 8.8e-12) tmp = Float64(y - Float64(log(y) * Float64(y + 0.5))); else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -18000.0) tmp = x - z; elseif (x <= -2.2e-56) tmp = (log(y) * -0.5) - z; elseif (x <= 8.8e-12) tmp = y - (log(y) * (y + 0.5)); else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -18000.0], N[(x - z), $MachinePrecision], If[LessEqual[x, -2.2e-56], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, 8.8e-12], N[(y - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -18000:\\
\;\;\;\;x - z\\
\mathbf{elif}\;x \leq -2.2 \cdot 10^{-56}:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{-12}:\\
\;\;\;\;y - \log y \cdot \left(y + 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if x < -18000 or 8.79999999999999966e-12 < 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 99.1%
log-rec99.1%
sub-neg99.1%
Simplified99.1%
Taylor expanded in y around 0 79.4%
neg-mul-179.4%
Simplified79.4%
if -18000 < x < -2.20000000000000004e-56Initial program 99.8%
associate--l+99.7%
sub-neg99.7%
associate-+l+99.7%
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 0 95.3%
associate-*r*95.3%
neg-mul-195.3%
+-commutative95.3%
cancel-sign-sub-inv95.3%
Simplified95.3%
Taylor expanded in y around 0 80.3%
*-commutative80.3%
Simplified80.3%
if -2.20000000000000004e-56 < x < 8.79999999999999966e-12Initial 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.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%
Simplified99.7%
Taylor expanded in z around 0 73.4%
+-commutative73.4%
Simplified73.4%
Final simplification76.6%
(FPCore (x y z) :precision binary64 (if (<= y 4e-7) (- (- 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 <= 4e-7) {
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 <= 4d-7) 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 <= 4e-7) {
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 <= 4e-7: 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 <= 4e-7) 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 <= 4e-7) 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, 4e-7], 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 4 \cdot 10^{-7}:\\
\;\;\;\;\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 < 3.9999999999999998e-7Initial program 99.9%
Taylor expanded in y around 0 99.7%
if 3.9999999999999998e-7 < y Initial 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 99.3%
log-rec99.3%
sub-neg99.3%
Simplified99.3%
Final simplification99.5%
(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.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -18000.0) (not (<= x 340000000000.0))) (- x z) (- (* (log y) -0.5) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -18000.0) || !(x <= 340000000000.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 <= (-18000.0d0)) .or. (.not. (x <= 340000000000.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 <= -18000.0) || !(x <= 340000000000.0)) {
tmp = x - z;
} else {
tmp = (Math.log(y) * -0.5) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -18000.0) or not (x <= 340000000000.0): tmp = x - z else: tmp = (math.log(y) * -0.5) - z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -18000.0) || !(x <= 340000000000.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 <= -18000.0) || ~((x <= 340000000000.0))) tmp = x - z; else tmp = (log(y) * -0.5) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -18000.0], N[Not[LessEqual[x, 340000000000.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 -18000 \lor \neg \left(x \leq 340000000000\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\end{array}
\end{array}
if x < -18000 or 3.4e11 < 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 99.9%
log-rec99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around 0 80.0%
neg-mul-180.0%
Simplified80.0%
if -18000 < x < 3.4e11Initial program 99.8%
associate--l+99.7%
sub-neg99.7%
associate-+l+99.7%
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 0 99.0%
associate-*r*99.0%
neg-mul-199.0%
+-commutative99.0%
cancel-sign-sub-inv99.0%
Simplified99.0%
Taylor expanded in y around 0 56.8%
*-commutative56.8%
Simplified56.8%
Final simplification66.7%
(FPCore (x y z) :precision binary64 (if (<= y 1.35e+103) (- (- 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.35e+103) {
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.35d+103) 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.35e+103) {
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.35e+103: 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.35e+103) 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.35e+103) 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.35e+103], 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.35 \cdot 10^{+103}:\\
\;\;\;\;\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.34999999999999996e103Initial program 99.9%
Taylor expanded in y around 0 91.5%
if 1.34999999999999996e103 < y Initial program 99.6%
Taylor expanded in y around inf 89.0%
*-commutative89.0%
log-rec89.0%
distribute-lft-neg-in89.0%
distribute-rgt-neg-in89.0%
Simplified89.0%
Taylor expanded in y around 0 89.1%
neg-mul-189.1%
sub-neg89.1%
Simplified89.1%
Final simplification90.7%
(FPCore (x y z) :precision binary64 (if (<= x -1.05e+132) x (if (<= x 1.04e+17) (- z) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.05e+132) {
tmp = x;
} else if (x <= 1.04e+17) {
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.05d+132)) then
tmp = x
else if (x <= 1.04d+17) 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.05e+132) {
tmp = x;
} else if (x <= 1.04e+17) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.05e+132: tmp = x elif x <= 1.04e+17: tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.05e+132) tmp = x; elseif (x <= 1.04e+17) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.05e+132) tmp = x; elseif (x <= 1.04e+17) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.05e+132], x, If[LessEqual[x, 1.04e+17], (-z), x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{+132}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.04 \cdot 10^{+17}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.04999999999999997e132 or 1.04e17 < 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 72.6%
if -1.04999999999999997e132 < x < 1.04e17Initial 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 z around inf 34.1%
neg-mul-134.1%
Simplified34.1%
Final simplification47.2%
(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 85.5%
log-rec85.5%
sub-neg85.5%
Simplified85.5%
Taylor expanded in y around 0 52.6%
neg-mul-152.6%
Simplified52.6%
Final simplification52.6%
(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 28.0%
Final simplification28.0%
(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 2023322
(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))