
(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 11 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 + fma(log(y), Float64(-0.5 - y), Float64(y - z))) end
code[x_, y_, z_] := N[(x + N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)
\end{array}
Initial program 99.8%
associate--l+99.8%
sub-neg99.8%
associate-+l+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 (+ x (- y (fma (log y) (+ y 0.5) z))))
double code(double x, double y, double z) {
return x + (y - fma(log(y), (y + 0.5), z));
}
function code(x, y, z) return Float64(x + Float64(y - fma(log(y), Float64(y + 0.5), z))) end
code[x_, y_, z_] := N[(x + N[(y - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - \mathsf{fma}\left(\log y, y + 0.5, z\right)\right)
\end{array}
Initial program 99.8%
associate--l+99.8%
sub-neg99.8%
associate-+l+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 0 99.9%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- x (* (log y) 0.5))))
(if (<= y 6.5e-228)
t_0
(if (<= y 1.26e-53)
(- (+ x y) z)
(if (<= y 6.1e-24)
t_0
(if (<= y 8.8e+18) (- x z) (+ x (* y (- 1.0 (log y))))))))))
double code(double x, double y, double z) {
double t_0 = x - (log(y) * 0.5);
double tmp;
if (y <= 6.5e-228) {
tmp = t_0;
} else if (y <= 1.26e-53) {
tmp = (x + y) - z;
} else if (y <= 6.1e-24) {
tmp = t_0;
} else if (y <= 8.8e+18) {
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) :: t_0
real(8) :: tmp
t_0 = x - (log(y) * 0.5d0)
if (y <= 6.5d-228) then
tmp = t_0
else if (y <= 1.26d-53) then
tmp = (x + y) - z
else if (y <= 6.1d-24) then
tmp = t_0
else if (y <= 8.8d+18) 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 t_0 = x - (Math.log(y) * 0.5);
double tmp;
if (y <= 6.5e-228) {
tmp = t_0;
} else if (y <= 1.26e-53) {
tmp = (x + y) - z;
} else if (y <= 6.1e-24) {
tmp = t_0;
} else if (y <= 8.8e+18) {
tmp = x - z;
} else {
tmp = x + (y * (1.0 - Math.log(y)));
}
return tmp;
}
def code(x, y, z): t_0 = x - (math.log(y) * 0.5) tmp = 0 if y <= 6.5e-228: tmp = t_0 elif y <= 1.26e-53: tmp = (x + y) - z elif y <= 6.1e-24: tmp = t_0 elif y <= 8.8e+18: tmp = x - z else: tmp = x + (y * (1.0 - math.log(y))) return tmp
function code(x, y, z) t_0 = Float64(x - Float64(log(y) * 0.5)) tmp = 0.0 if (y <= 6.5e-228) tmp = t_0; elseif (y <= 1.26e-53) tmp = Float64(Float64(x + y) - z); elseif (y <= 6.1e-24) tmp = t_0; elseif (y <= 8.8e+18) 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) t_0 = x - (log(y) * 0.5); tmp = 0.0; if (y <= 6.5e-228) tmp = t_0; elseif (y <= 1.26e-53) tmp = (x + y) - z; elseif (y <= 6.1e-24) tmp = t_0; elseif (y <= 8.8e+18) tmp = x - z; else tmp = x + (y * (1.0 - log(y))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 6.5e-228], t$95$0, If[LessEqual[y, 1.26e-53], N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[y, 6.1e-24], t$95$0, If[LessEqual[y, 8.8e+18], N[(x - z), $MachinePrecision], N[(x + N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \log y \cdot 0.5\\
\mathbf{if}\;y \leq 6.5 \cdot 10^{-228}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.26 \cdot 10^{-53}:\\
\;\;\;\;\left(x + y\right) - z\\
\mathbf{elif}\;y \leq 6.1 \cdot 10^{-24}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 8.8 \cdot 10^{+18}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 6.50000000000000029e-228 or 1.26e-53 < y < 6.10000000000000036e-24Initial program 100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in z around 0 90.7%
if 6.50000000000000029e-228 < y < 1.26e-53Initial program 100.0%
expm1-log1p-u68.6%
sub-neg68.6%
distribute-lft-neg-in68.6%
+-commutative68.6%
distribute-neg-in68.6%
metadata-eval68.6%
sub-neg68.6%
*-commutative68.6%
Applied egg-rr68.6%
Taylor expanded in x around inf 78.5%
if 6.10000000000000036e-24 < y < 8.8e18Initial program 99.9%
add-cube-cbrt99.3%
pow399.3%
sub-neg99.3%
associate-+l+99.3%
distribute-lft-neg-in99.3%
+-commutative99.3%
distribute-neg-in99.3%
metadata-eval99.3%
sub-neg99.3%
*-commutative99.3%
Applied egg-rr99.3%
add-cube-cbrt99.2%
pow399.2%
fma-def99.2%
Applied egg-rr99.2%
Taylor expanded in y around inf 81.8%
pow-base-181.8%
*-lft-identity81.8%
Simplified81.8%
if 8.8e18 < y Initial program 99.6%
associate--l+99.6%
sub-neg99.6%
associate-+l+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 83.5%
log-rec83.5%
sub-neg83.5%
Simplified83.5%
Final simplification83.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -7.4e+22) (not (<= x 8e+78))) (+ x (* y (- 1.0 (log y)))) (- (- y (* (log y) (+ y 0.5))) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -7.4e+22) || !(x <= 8e+78)) {
tmp = x + (y * (1.0 - log(y)));
} else {
tmp = (y - (log(y) * (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 <= (-7.4d+22)) .or. (.not. (x <= 8d+78))) then
tmp = x + (y * (1.0d0 - log(y)))
else
tmp = (y - (log(y) * (y + 0.5d0))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -7.4e+22) || !(x <= 8e+78)) {
tmp = x + (y * (1.0 - Math.log(y)));
} else {
tmp = (y - (Math.log(y) * (y + 0.5))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -7.4e+22) or not (x <= 8e+78): tmp = x + (y * (1.0 - math.log(y))) else: tmp = (y - (math.log(y) * (y + 0.5))) - z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -7.4e+22) || !(x <= 8e+78)) tmp = Float64(x + Float64(y * Float64(1.0 - log(y)))); else tmp = Float64(Float64(y - Float64(log(y) * Float64(y + 0.5))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -7.4e+22) || ~((x <= 8e+78))) tmp = x + (y * (1.0 - log(y))); else tmp = (y - (log(y) * (y + 0.5))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -7.4e+22], N[Not[LessEqual[x, 8e+78]], $MachinePrecision]], N[(x + N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.4 \cdot 10^{+22} \lor \neg \left(x \leq 8 \cdot 10^{+78}\right):\\
\;\;\;\;x + y \cdot \left(1 - \log y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y - \log y \cdot \left(y + 0.5\right)\right) - z\\
\end{array}
\end{array}
if x < -7.3999999999999996e22 or 8.00000000000000007e78 < x Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
associate-+l+100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
fma-def100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 87.6%
log-rec87.6%
sub-neg87.6%
Simplified87.6%
if -7.3999999999999996e22 < x < 8.00000000000000007e78Initial program 99.7%
Taylor expanded in x around 0 98.3%
Final simplification94.2%
(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 (<= z -330000000000.0) (not (<= z 202.0))) (- x z) (- x (* (log y) 0.5))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -330000000000.0) || !(z <= 202.0)) {
tmp = x - z;
} else {
tmp = x - (log(y) * 0.5);
}
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 <= (-330000000000.0d0)) .or. (.not. (z <= 202.0d0))) then
tmp = x - z
else
tmp = x - (log(y) * 0.5d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -330000000000.0) || !(z <= 202.0)) {
tmp = x - z;
} else {
tmp = x - (Math.log(y) * 0.5);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -330000000000.0) or not (z <= 202.0): tmp = x - z else: tmp = x - (math.log(y) * 0.5) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -330000000000.0) || !(z <= 202.0)) tmp = Float64(x - z); else tmp = Float64(x - Float64(log(y) * 0.5)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -330000000000.0) || ~((z <= 202.0))) tmp = x - z; else tmp = x - (log(y) * 0.5); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -330000000000.0], N[Not[LessEqual[z, 202.0]], $MachinePrecision]], N[(x - z), $MachinePrecision], N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -330000000000 \lor \neg \left(z \leq 202\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;x - \log y \cdot 0.5\\
\end{array}
\end{array}
if z < -3.3e11 or 202 < z Initial program 99.9%
add-cube-cbrt99.0%
pow399.0%
sub-neg99.0%
associate-+l+99.0%
distribute-lft-neg-in99.0%
+-commutative99.0%
distribute-neg-in99.0%
metadata-eval99.0%
sub-neg99.0%
*-commutative99.0%
Applied egg-rr99.0%
add-cube-cbrt99.0%
pow399.0%
fma-def98.9%
Applied egg-rr98.9%
Taylor expanded in y around inf 71.3%
pow-base-171.3%
*-lft-identity71.3%
Simplified71.3%
if -3.3e11 < z < 202Initial program 99.7%
Taylor expanded in y around 0 57.5%
Taylor expanded in z around 0 57.5%
Final simplification64.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -130.0) (not (<= x 4.55e+36))) (- x z) (- (* (log y) -0.5) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -130.0) || !(x <= 4.55e+36)) {
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 <= (-130.0d0)) .or. (.not. (x <= 4.55d+36))) 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 <= -130.0) || !(x <= 4.55e+36)) {
tmp = x - z;
} else {
tmp = (Math.log(y) * -0.5) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -130.0) or not (x <= 4.55e+36): tmp = x - z else: tmp = (math.log(y) * -0.5) - z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -130.0) || !(x <= 4.55e+36)) 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 <= -130.0) || ~((x <= 4.55e+36))) tmp = x - z; else tmp = (log(y) * -0.5) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -130.0], N[Not[LessEqual[x, 4.55e+36]], $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 -130 \lor \neg \left(x \leq 4.55 \cdot 10^{+36}\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\end{array}
\end{array}
if x < -130 or 4.54999999999999995e36 < x Initial program 99.9%
add-cube-cbrt98.3%
pow398.3%
sub-neg98.3%
associate-+l+98.3%
distribute-lft-neg-in98.3%
+-commutative98.3%
distribute-neg-in98.3%
metadata-eval98.3%
sub-neg98.3%
*-commutative98.3%
Applied egg-rr98.3%
add-cube-cbrt98.2%
pow398.3%
fma-def98.3%
Applied egg-rr98.3%
Taylor expanded in y around inf 74.7%
pow-base-174.7%
*-lft-identity74.7%
Simplified74.7%
if -130 < x < 4.54999999999999995e36Initial program 99.7%
flip-+72.2%
associate-*l/72.2%
fma-neg72.2%
metadata-eval72.2%
metadata-eval72.2%
sub-neg72.2%
metadata-eval72.2%
Applied egg-rr72.2%
Taylor expanded in x around 0 72.0%
Taylor expanded in y around 0 55.8%
Final simplification64.1%
(FPCore (x y z) :precision binary64 (if (<= y 65000000000000.0) (- (- x (* (log y) 0.5)) z) (+ x (* y (- 1.0 (log y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 65000000000000.0) {
tmp = (x - (log(y) * 0.5)) - 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 <= 65000000000000.0d0) then
tmp = (x - (log(y) * 0.5d0)) - 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 <= 65000000000000.0) {
tmp = (x - (Math.log(y) * 0.5)) - z;
} else {
tmp = x + (y * (1.0 - Math.log(y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 65000000000000.0: tmp = (x - (math.log(y) * 0.5)) - z else: tmp = x + (y * (1.0 - math.log(y))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 65000000000000.0) tmp = Float64(Float64(x - Float64(log(y) * 0.5)) - 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 <= 65000000000000.0) tmp = (x - (log(y) * 0.5)) - z; else tmp = x + (y * (1.0 - log(y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 65000000000000.0], N[(N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] - 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 65000000000000:\\
\;\;\;\;\left(x - \log y \cdot 0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 6.5e13Initial program 100.0%
Taylor expanded in y around 0 98.8%
if 6.5e13 < y Initial program 99.6%
associate--l+99.6%
sub-neg99.6%
associate-+l+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 83.5%
log-rec83.5%
sub-neg83.5%
Simplified83.5%
Final simplification90.7%
(FPCore (x y z) :precision binary64 (if (<= x -3e+24) x (if (<= x 1.65e+38) (- z) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -3e+24) {
tmp = x;
} else if (x <= 1.65e+38) {
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 <= (-3d+24)) then
tmp = x
else if (x <= 1.65d+38) 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 <= -3e+24) {
tmp = x;
} else if (x <= 1.65e+38) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3e+24: tmp = x elif x <= 1.65e+38: tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3e+24) tmp = x; elseif (x <= 1.65e+38) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3e+24) tmp = x; elseif (x <= 1.65e+38) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3e+24], x, If[LessEqual[x, 1.65e+38], (-z), x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{+24}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{+38}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -2.99999999999999995e24 or 1.65e38 < x Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
associate-+l+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 x around inf 63.1%
if -2.99999999999999995e24 < x < 1.65e38Initial program 99.7%
Taylor expanded in y around 0 55.6%
Taylor expanded in z around inf 34.1%
neg-mul-134.1%
Simplified34.1%
Final simplification46.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.8%
add-cube-cbrt98.5%
pow398.5%
sub-neg98.5%
associate-+l+98.5%
distribute-lft-neg-in98.5%
+-commutative98.5%
distribute-neg-in98.5%
metadata-eval98.5%
sub-neg98.5%
*-commutative98.5%
Applied egg-rr98.5%
add-cube-cbrt98.4%
pow398.4%
fma-def98.4%
Applied egg-rr98.4%
Taylor expanded in y around inf 51.4%
pow-base-151.4%
*-lft-identity51.4%
Simplified51.4%
Final simplification51.4%
(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%
*-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 27.3%
Final simplification27.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 2023318
(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))