
(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 9 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 (- (+ y (- x (* (+ y 0.5) (log y)))) z))
double code(double x, double y, double z) {
return (y + (x - ((y + 0.5) * log(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 = (y + (x - ((y + 0.5d0) * log(y)))) - z
end function
public static double code(double x, double y, double z) {
return (y + (x - ((y + 0.5) * Math.log(y)))) - z;
}
def code(x, y, z): return (y + (x - ((y + 0.5) * math.log(y)))) - z
function code(x, y, z) return Float64(Float64(y + Float64(x - Float64(Float64(y + 0.5) * log(y)))) - z) end
function tmp = code(x, y, z) tmp = (y + (x - ((y + 0.5) * log(y)))) - z; end
code[x_, y_, z_] := N[(N[(y + N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(y + \left(x - \left(y + 0.5\right) \cdot \log y\right)\right) - z
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (log y) -0.5) z)) (t_1 (- x (* 0.5 (log y)))))
(if (<= y 1.62e-270)
t_0
(if (<= y 2.7e-82)
t_1
(if (<= y 3.3e+62)
t_0
(if (<= y 1.05e+91) t_1 (* y (- 1.0 (log y)))))))))
double code(double x, double y, double z) {
double t_0 = (log(y) * -0.5) - z;
double t_1 = x - (0.5 * log(y));
double tmp;
if (y <= 1.62e-270) {
tmp = t_0;
} else if (y <= 2.7e-82) {
tmp = t_1;
} else if (y <= 3.3e+62) {
tmp = t_0;
} else if (y <= 1.05e+91) {
tmp = t_1;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (log(y) * (-0.5d0)) - z
t_1 = x - (0.5d0 * log(y))
if (y <= 1.62d-270) then
tmp = t_0
else if (y <= 2.7d-82) then
tmp = t_1
else if (y <= 3.3d+62) then
tmp = t_0
else if (y <= 1.05d+91) then
tmp = t_1
else
tmp = y * (1.0d0 - log(y))
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 t_1 = x - (0.5 * Math.log(y));
double tmp;
if (y <= 1.62e-270) {
tmp = t_0;
} else if (y <= 2.7e-82) {
tmp = t_1;
} else if (y <= 3.3e+62) {
tmp = t_0;
} else if (y <= 1.05e+91) {
tmp = t_1;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): t_0 = (math.log(y) * -0.5) - z t_1 = x - (0.5 * math.log(y)) tmp = 0 if y <= 1.62e-270: tmp = t_0 elif y <= 2.7e-82: tmp = t_1 elif y <= 3.3e+62: tmp = t_0 elif y <= 1.05e+91: tmp = t_1 else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) t_0 = Float64(Float64(log(y) * -0.5) - z) t_1 = Float64(x - Float64(0.5 * log(y))) tmp = 0.0 if (y <= 1.62e-270) tmp = t_0; elseif (y <= 2.7e-82) tmp = t_1; elseif (y <= 3.3e+62) tmp = t_0; elseif (y <= 1.05e+91) tmp = t_1; else tmp = Float64(y * Float64(1.0 - log(y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (log(y) * -0.5) - z; t_1 = x - (0.5 * log(y)); tmp = 0.0; if (y <= 1.62e-270) tmp = t_0; elseif (y <= 2.7e-82) tmp = t_1; elseif (y <= 3.3e+62) tmp = t_0; elseif (y <= 1.05e+91) tmp = t_1; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(x - N[(0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1.62e-270], t$95$0, If[LessEqual[y, 2.7e-82], t$95$1, If[LessEqual[y, 3.3e+62], t$95$0, If[LessEqual[y, 1.05e+91], t$95$1, N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log y \cdot -0.5 - z\\
t_1 := x - 0.5 \cdot \log y\\
\mathbf{if}\;y \leq 1.62 \cdot 10^{-270}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{-82}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{+62}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{+91}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 1.61999999999999992e-270 or 2.7000000000000001e-82 < y < 3.3e62Initial program 100.0%
Taylor expanded in y around 0 93.4%
Taylor expanded in x around 0 70.8%
mul-1-neg70.8%
neg-sub070.8%
+-commutative70.8%
associate--r+70.8%
neg-sub070.8%
distribute-lft-neg-in70.8%
metadata-eval70.8%
*-commutative70.8%
Simplified70.8%
if 1.61999999999999992e-270 < y < 2.7000000000000001e-82 or 3.3e62 < y < 1.05000000000000004e91Initial program 100.0%
Taylor expanded in y around 0 97.9%
Taylor expanded in z around 0 71.7%
if 1.05000000000000004e91 < y Initial program 99.7%
associate--l+99.6%
sub-neg99.6%
associate-+l+99.6%
associate-+r-99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
fma-define99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 71.6%
log-rec71.6%
sub-neg71.6%
Simplified71.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- x (* 0.5 (log y)))))
(if (<= y 9.5e-270)
(- z)
(if (<= y 4e+19)
t_0
(if (<= y 2.65e+63)
(- z)
(if (<= y 2.4e+91) t_0 (* y (- 1.0 (log y)))))))))
double code(double x, double y, double z) {
double t_0 = x - (0.5 * log(y));
double tmp;
if (y <= 9.5e-270) {
tmp = -z;
} else if (y <= 4e+19) {
tmp = t_0;
} else if (y <= 2.65e+63) {
tmp = -z;
} else if (y <= 2.4e+91) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x - (0.5d0 * log(y))
if (y <= 9.5d-270) then
tmp = -z
else if (y <= 4d+19) then
tmp = t_0
else if (y <= 2.65d+63) then
tmp = -z
else if (y <= 2.4d+91) then
tmp = t_0
else
tmp = y * (1.0d0 - log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x - (0.5 * Math.log(y));
double tmp;
if (y <= 9.5e-270) {
tmp = -z;
} else if (y <= 4e+19) {
tmp = t_0;
} else if (y <= 2.65e+63) {
tmp = -z;
} else if (y <= 2.4e+91) {
tmp = t_0;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): t_0 = x - (0.5 * math.log(y)) tmp = 0 if y <= 9.5e-270: tmp = -z elif y <= 4e+19: tmp = t_0 elif y <= 2.65e+63: tmp = -z elif y <= 2.4e+91: tmp = t_0 else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) t_0 = Float64(x - Float64(0.5 * log(y))) tmp = 0.0 if (y <= 9.5e-270) tmp = Float64(-z); elseif (y <= 4e+19) tmp = t_0; elseif (y <= 2.65e+63) tmp = Float64(-z); elseif (y <= 2.4e+91) tmp = t_0; else tmp = Float64(y * Float64(1.0 - log(y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x - (0.5 * log(y)); tmp = 0.0; if (y <= 9.5e-270) tmp = -z; elseif (y <= 4e+19) tmp = t_0; elseif (y <= 2.65e+63) tmp = -z; elseif (y <= 2.4e+91) tmp = t_0; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x - N[(0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 9.5e-270], (-z), If[LessEqual[y, 4e+19], t$95$0, If[LessEqual[y, 2.65e+63], (-z), If[LessEqual[y, 2.4e+91], t$95$0, N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - 0.5 \cdot \log y\\
\mathbf{if}\;y \leq 9.5 \cdot 10^{-270}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.65 \cdot 10^{+63}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+91}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 9.5000000000000006e-270 or 4e19 < y < 2.65e63Initial 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-define99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 72.5%
neg-mul-172.5%
Simplified72.5%
if 9.5000000000000006e-270 < y < 4e19 or 2.65e63 < y < 2.39999999999999983e91Initial program 100.0%
Taylor expanded in y around 0 96.3%
Taylor expanded in z around 0 64.2%
if 2.39999999999999983e91 < y Initial program 99.7%
associate--l+99.6%
sub-neg99.6%
associate-+l+99.6%
associate-+r-99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
fma-define99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 71.6%
log-rec71.6%
sub-neg71.6%
Simplified71.6%
(FPCore (x y z)
:precision binary64
(if (<= y 1.65e-269)
(- z)
(if (<= y 2.56e-82)
x
(if (<= y 1.2e+63) (- z) (if (<= y 1e+91) x (* y (- 1.0 (log y))))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.65e-269) {
tmp = -z;
} else if (y <= 2.56e-82) {
tmp = x;
} else if (y <= 1.2e+63) {
tmp = -z;
} else if (y <= 1e+91) {
tmp = x;
} 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 <= 1.65d-269) then
tmp = -z
else if (y <= 2.56d-82) then
tmp = x
else if (y <= 1.2d+63) then
tmp = -z
else if (y <= 1d+91) then
tmp = x
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 <= 1.65e-269) {
tmp = -z;
} else if (y <= 2.56e-82) {
tmp = x;
} else if (y <= 1.2e+63) {
tmp = -z;
} else if (y <= 1e+91) {
tmp = x;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.65e-269: tmp = -z elif y <= 2.56e-82: tmp = x elif y <= 1.2e+63: tmp = -z elif y <= 1e+91: tmp = x else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.65e-269) tmp = Float64(-z); elseif (y <= 2.56e-82) tmp = x; elseif (y <= 1.2e+63) tmp = Float64(-z); elseif (y <= 1e+91) tmp = x; 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 <= 1.65e-269) tmp = -z; elseif (y <= 2.56e-82) tmp = x; elseif (y <= 1.2e+63) tmp = -z; elseif (y <= 1e+91) tmp = x; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.65e-269], (-z), If[LessEqual[y, 2.56e-82], x, If[LessEqual[y, 1.2e+63], (-z), If[LessEqual[y, 1e+91], x, N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.65 \cdot 10^{-269}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 2.56 \cdot 10^{-82}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{+63}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 10^{+91}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 1.65e-269 or 2.5600000000000001e-82 < y < 1.2e63Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
associate-+l+100.0%
associate-+r-100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
fma-define99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 56.0%
neg-mul-156.0%
Simplified56.0%
if 1.65e-269 < y < 2.5600000000000001e-82 or 1.2e63 < y < 1.00000000000000008e91Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
associate-+l+100.0%
associate-+r-100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
fma-define100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 49.3%
if 1.00000000000000008e91 < y Initial program 99.7%
associate--l+99.6%
sub-neg99.6%
associate-+l+99.6%
associate-+r-99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
fma-define99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 71.6%
log-rec71.6%
sub-neg71.6%
Simplified71.6%
(FPCore (x y z) :precision binary64 (if (<= y 2.65e+91) (- (- x (* 0.5 (log y))) z) (- (- y (* (+ y 0.5) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.65e+91) {
tmp = (x - (0.5 * log(y))) - z;
} else {
tmp = (y - ((y + 0.5) * 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 <= 2.65d+91) then
tmp = (x - (0.5d0 * log(y))) - z
else
tmp = (y - ((y + 0.5d0) * log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.65e+91) {
tmp = (x - (0.5 * Math.log(y))) - z;
} else {
tmp = (y - ((y + 0.5) * Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.65e+91: tmp = (x - (0.5 * math.log(y))) - z else: tmp = (y - ((y + 0.5) * math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.65e+91) tmp = Float64(Float64(x - Float64(0.5 * log(y))) - z); else tmp = Float64(Float64(y - Float64(Float64(y + 0.5) * log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.65e+91) tmp = (x - (0.5 * log(y))) - z; else tmp = (y - ((y + 0.5) * log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.65e+91], N[(N[(x - N[(0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(y - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.65 \cdot 10^{+91}:\\
\;\;\;\;\left(x - 0.5 \cdot \log y\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(y - \left(y + 0.5\right) \cdot \log y\right) - z\\
\end{array}
\end{array}
if y < 2.64999999999999998e91Initial program 100.0%
Taylor expanded in y around 0 95.9%
if 2.64999999999999998e91 < y Initial program 99.7%
associate--l+99.6%
sub-neg99.6%
associate-+l+99.6%
associate-+r-99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
fma-define99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 87.0%
associate-*r*87.0%
mul-1-neg87.0%
+-commutative87.0%
cancel-sign-sub-inv87.0%
Simplified87.0%
Final simplification92.6%
(FPCore (x y z) :precision binary64 (if (<= y 5.2e+99) (- (- x (* 0.5 (log y))) z) (- x (* y (+ (log y) -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 5.2e+99) {
tmp = (x - (0.5 * log(y))) - z;
} else {
tmp = x - (y * (log(y) + -1.0));
}
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.2d+99) then
tmp = (x - (0.5d0 * log(y))) - z
else
tmp = x - (y * (log(y) + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 5.2e+99) {
tmp = (x - (0.5 * Math.log(y))) - z;
} else {
tmp = x - (y * (Math.log(y) + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5.2e+99: tmp = (x - (0.5 * math.log(y))) - z else: tmp = x - (y * (math.log(y) + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5.2e+99) tmp = Float64(Float64(x - Float64(0.5 * log(y))) - z); else tmp = Float64(x - Float64(y * Float64(log(y) + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 5.2e+99) tmp = (x - (0.5 * log(y))) - z; else tmp = x - (y * (log(y) + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5.2e+99], N[(N[(x - N[(0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(x - N[(y * N[(N[Log[y], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.2 \cdot 10^{+99}:\\
\;\;\;\;\left(x - 0.5 \cdot \log y\right) - z\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \left(\log y + -1\right)\\
\end{array}
\end{array}
if y < 5.1999999999999999e99Initial program 100.0%
Taylor expanded in y around 0 95.0%
if 5.1999999999999999e99 < y Initial program 99.7%
associate--l+99.6%
sub-neg99.6%
associate-+l+99.6%
associate-+r-99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
fma-define99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around -inf 65.5%
associate-*r*65.5%
neg-mul-165.5%
mul-1-neg65.5%
associate-*r*65.5%
mul-1-neg65.5%
+-commutative65.5%
cancel-sign-sub-inv65.5%
Simplified65.5%
Taylor expanded in y around inf 86.4%
mul-1-neg86.4%
associate-*r*70.5%
distribute-lft-neg-in70.5%
sub-neg70.5%
mul-1-neg70.5%
log-rec70.5%
distribute-frac-neg70.5%
remove-double-neg70.5%
distribute-neg-frac70.5%
metadata-eval70.5%
Simplified70.5%
Taylor expanded in z around 0 86.6%
mul-1-neg86.6%
*-commutative86.6%
distribute-rgt-neg-in86.6%
sub-neg86.6%
metadata-eval86.6%
Simplified86.6%
Final simplification92.1%
(FPCore (x y z) :precision binary64 (if (<= y 7e+99) (- (- x (* 0.5 (log y))) z) (* y (- 1.0 (log y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 7e+99) {
tmp = (x - (0.5 * log(y))) - 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 <= 7d+99) then
tmp = (x - (0.5d0 * log(y))) - 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 <= 7e+99) {
tmp = (x - (0.5 * Math.log(y))) - z;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 7e+99: tmp = (x - (0.5 * math.log(y))) - z else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 7e+99) tmp = Float64(Float64(x - Float64(0.5 * log(y))) - 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 <= 7e+99) tmp = (x - (0.5 * log(y))) - z; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 7e+99], N[(N[(x - N[(0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{+99}:\\
\;\;\;\;\left(x - 0.5 \cdot \log y\right) - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 6.9999999999999995e99Initial program 100.0%
Taylor expanded in y around 0 95.0%
if 6.9999999999999995e99 < y Initial program 99.7%
associate--l+99.6%
sub-neg99.6%
associate-+l+99.6%
associate-+r-99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
fma-define99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 74.3%
log-rec74.3%
sub-neg74.3%
Simplified74.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -65000000000000.0) (not (<= z 4.8e+53))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -65000000000000.0) || !(z <= 4.8e+53)) {
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 ((z <= (-65000000000000.0d0)) .or. (.not. (z <= 4.8d+53))) 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 ((z <= -65000000000000.0) || !(z <= 4.8e+53)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -65000000000000.0) or not (z <= 4.8e+53): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -65000000000000.0) || !(z <= 4.8e+53)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -65000000000000.0) || ~((z <= 4.8e+53))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -65000000000000.0], N[Not[LessEqual[z, 4.8e+53]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -65000000000000 \lor \neg \left(z \leq 4.8 \cdot 10^{+53}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6.5e13 or 4.8e53 < z 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-define99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 63.6%
neg-mul-163.6%
Simplified63.6%
if -6.5e13 < z < 4.8e53Initial 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-define99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 39.5%
Final simplification50.3%
(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.9%
associate--l+99.9%
sub-neg99.9%
associate-+l+99.9%
associate-+r-99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-define99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 29.4%
(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 2024167
(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))