
(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 12 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
(let* ((t_0 (* y (- 1.0 (log y)))) (t_1 (- x (* (log y) 0.5))))
(if (<= z -6000000000.0)
(- x z)
(if (<= z -2.15e-234)
t_1
(if (<= z 1.15e-306)
t_0
(if (<= z 1.4e-18) t_1 (if (<= z 0.11) t_0 (- x z))))))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - log(y));
double t_1 = x - (log(y) * 0.5);
double tmp;
if (z <= -6000000000.0) {
tmp = x - z;
} else if (z <= -2.15e-234) {
tmp = t_1;
} else if (z <= 1.15e-306) {
tmp = t_0;
} else if (z <= 1.4e-18) {
tmp = t_1;
} else if (z <= 0.11) {
tmp = t_0;
} else {
tmp = x - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y * (1.0d0 - log(y))
t_1 = x - (log(y) * 0.5d0)
if (z <= (-6000000000.0d0)) then
tmp = x - z
else if (z <= (-2.15d-234)) then
tmp = t_1
else if (z <= 1.15d-306) then
tmp = t_0
else if (z <= 1.4d-18) then
tmp = t_1
else if (z <= 0.11d0) then
tmp = t_0
else
tmp = x - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (1.0 - Math.log(y));
double t_1 = x - (Math.log(y) * 0.5);
double tmp;
if (z <= -6000000000.0) {
tmp = x - z;
} else if (z <= -2.15e-234) {
tmp = t_1;
} else if (z <= 1.15e-306) {
tmp = t_0;
} else if (z <= 1.4e-18) {
tmp = t_1;
} else if (z <= 0.11) {
tmp = t_0;
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 - math.log(y)) t_1 = x - (math.log(y) * 0.5) tmp = 0 if z <= -6000000000.0: tmp = x - z elif z <= -2.15e-234: tmp = t_1 elif z <= 1.15e-306: tmp = t_0 elif z <= 1.4e-18: tmp = t_1 elif z <= 0.11: tmp = t_0 else: tmp = x - z return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - log(y))) t_1 = Float64(x - Float64(log(y) * 0.5)) tmp = 0.0 if (z <= -6000000000.0) tmp = Float64(x - z); elseif (z <= -2.15e-234) tmp = t_1; elseif (z <= 1.15e-306) tmp = t_0; elseif (z <= 1.4e-18) tmp = t_1; elseif (z <= 0.11) tmp = t_0; else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 - log(y)); t_1 = x - (log(y) * 0.5); tmp = 0.0; if (z <= -6000000000.0) tmp = x - z; elseif (z <= -2.15e-234) tmp = t_1; elseif (z <= 1.15e-306) tmp = t_0; elseif (z <= 1.4e-18) tmp = t_1; elseif (z <= 0.11) tmp = t_0; else tmp = x - 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]}, Block[{t$95$1 = N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6000000000.0], N[(x - z), $MachinePrecision], If[LessEqual[z, -2.15e-234], t$95$1, If[LessEqual[z, 1.15e-306], t$95$0, If[LessEqual[z, 1.4e-18], t$95$1, If[LessEqual[z, 0.11], t$95$0, N[(x - z), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - \log y\right)\\
t_1 := x - \log y \cdot 0.5\\
\mathbf{if}\;z \leq -6000000000:\\
\;\;\;\;x - z\\
\mathbf{elif}\;z \leq -2.15 \cdot 10^{-234}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{-306}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{-18}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 0.11:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if z < -6e9 or 0.110000000000000001 < z Initial program 99.9%
associate--l+99.9%
associate-+l-99.9%
Simplified99.9%
Taylor expanded in z around inf 87.3%
if -6e9 < z < -2.15e-234 or 1.14999999999999995e-306 < z < 1.40000000000000006e-18Initial program 99.8%
associate--l+99.8%
associate-+l-99.8%
Simplified99.8%
Taylor expanded in z around 0 98.9%
Taylor expanded in y around 0 69.1%
if -2.15e-234 < z < 1.14999999999999995e-306 or 1.40000000000000006e-18 < z < 0.110000000000000001Initial program 99.2%
associate--l+99.2%
associate-+l-99.2%
Simplified99.2%
Taylor expanded in z around 0 96.0%
Taylor expanded in y around inf 77.7%
mul-1-neg77.7%
log-rec77.7%
remove-double-neg77.7%
Simplified77.7%
Final simplification78.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (log y) -0.5) z)))
(if (<= x -32000000.0)
(- x z)
(if (<= x 1.85e-249)
t_0
(if (<= x 3e-187)
(* y (- 1.0 (log y)))
(if (<= x 0.0026) t_0 (- x z)))))))
double code(double x, double y, double z) {
double t_0 = (log(y) * -0.5) - z;
double tmp;
if (x <= -32000000.0) {
tmp = x - z;
} else if (x <= 1.85e-249) {
tmp = t_0;
} else if (x <= 3e-187) {
tmp = y * (1.0 - log(y));
} else if (x <= 0.0026) {
tmp = t_0;
} else {
tmp = x - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (log(y) * (-0.5d0)) - z
if (x <= (-32000000.0d0)) then
tmp = x - z
else if (x <= 1.85d-249) then
tmp = t_0
else if (x <= 3d-187) then
tmp = y * (1.0d0 - log(y))
else if (x <= 0.0026d0) then
tmp = t_0
else
tmp = x - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (Math.log(y) * -0.5) - z;
double tmp;
if (x <= -32000000.0) {
tmp = x - z;
} else if (x <= 1.85e-249) {
tmp = t_0;
} else if (x <= 3e-187) {
tmp = y * (1.0 - Math.log(y));
} else if (x <= 0.0026) {
tmp = t_0;
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): t_0 = (math.log(y) * -0.5) - z tmp = 0 if x <= -32000000.0: tmp = x - z elif x <= 1.85e-249: tmp = t_0 elif x <= 3e-187: tmp = y * (1.0 - math.log(y)) elif x <= 0.0026: tmp = t_0 else: tmp = x - z return tmp
function code(x, y, z) t_0 = Float64(Float64(log(y) * -0.5) - z) tmp = 0.0 if (x <= -32000000.0) tmp = Float64(x - z); elseif (x <= 1.85e-249) tmp = t_0; elseif (x <= 3e-187) tmp = Float64(y * Float64(1.0 - log(y))); elseif (x <= 0.0026) tmp = t_0; else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (log(y) * -0.5) - z; tmp = 0.0; if (x <= -32000000.0) tmp = x - z; elseif (x <= 1.85e-249) tmp = t_0; elseif (x <= 3e-187) tmp = y * (1.0 - log(y)); elseif (x <= 0.0026) tmp = t_0; else tmp = x - 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[x, -32000000.0], N[(x - z), $MachinePrecision], If[LessEqual[x, 1.85e-249], t$95$0, If[LessEqual[x, 3e-187], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.0026], t$95$0, N[(x - z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log y \cdot -0.5 - z\\
\mathbf{if}\;x \leq -32000000:\\
\;\;\;\;x - z\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{-249}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3 \cdot 10^{-187}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\mathbf{elif}\;x \leq 0.0026:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if x < -3.2e7 or 0.0025999999999999999 < x Initial program 99.9%
associate--l+99.9%
associate-+l-99.9%
Simplified99.9%
Taylor expanded in z around inf 83.6%
if -3.2e7 < x < 1.84999999999999988e-249 or 3.00000000000000004e-187 < x < 0.0025999999999999999Initial program 99.8%
associate--l+99.8%
sub-neg99.8%
associate-+l+99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
fma-def99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
add-cube-cbrt98.1%
pow398.2%
+-commutative98.2%
Applied egg-rr98.2%
Taylor expanded in x around 0 50.1%
unpow1/397.6%
mul-1-neg97.6%
unsub-neg97.6%
+-commutative97.6%
Simplified97.6%
Taylor expanded in y around 0 71.5%
mul-1-neg71.5%
pow-base-171.5%
*-lft-identity71.5%
distribute-neg-in71.5%
distribute-lft-neg-in71.5%
metadata-eval71.5%
*-commutative71.5%
Simplified71.5%
if 1.84999999999999988e-249 < x < 3.00000000000000004e-187Initial program 99.6%
associate--l+99.6%
associate-+l-99.6%
Simplified99.6%
Taylor expanded in z around 0 75.7%
Taylor expanded in y around inf 74.7%
mul-1-neg74.7%
log-rec74.7%
remove-double-neg74.7%
Simplified74.7%
Final simplification77.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -330000000000.0) (not (<= z 0.0069))) (- (- x (* (log y) 0.5)) z) (- (+ x y) (* (log y) (+ y 0.5)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -330000000000.0) || !(z <= 0.0069)) {
tmp = (x - (log(y) * 0.5)) - z;
} else {
tmp = (x + y) - (log(y) * (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 <= 0.0069d0))) then
tmp = (x - (log(y) * 0.5d0)) - z
else
tmp = (x + y) - (log(y) * (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 <= 0.0069)) {
tmp = (x - (Math.log(y) * 0.5)) - z;
} else {
tmp = (x + y) - (Math.log(y) * (y + 0.5));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -330000000000.0) or not (z <= 0.0069): tmp = (x - (math.log(y) * 0.5)) - z else: tmp = (x + y) - (math.log(y) * (y + 0.5)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -330000000000.0) || !(z <= 0.0069)) tmp = Float64(Float64(x - Float64(log(y) * 0.5)) - z); else tmp = Float64(Float64(x + y) - Float64(log(y) * Float64(y + 0.5))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -330000000000.0) || ~((z <= 0.0069))) tmp = (x - (log(y) * 0.5)) - z; else tmp = (x + y) - (log(y) * (y + 0.5)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -330000000000.0], N[Not[LessEqual[z, 0.0069]], $MachinePrecision]], N[(N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x + y), $MachinePrecision] - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -330000000000 \lor \neg \left(z \leq 0.0069\right):\\
\;\;\;\;\left(x - \log y \cdot 0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) - \log y \cdot \left(y + 0.5\right)\\
\end{array}
\end{array}
if z < -3.3e11 or 0.0068999999999999999 < z Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
associate-+l+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 0 88.8%
metadata-eval88.8%
cancel-sign-sub-inv88.8%
*-commutative88.8%
Simplified88.8%
if -3.3e11 < z < 0.0068999999999999999Initial program 99.7%
associate--l+99.7%
associate-+l-99.7%
Simplified99.7%
Taylor expanded in z around 0 98.9%
Final simplification93.8%
(FPCore (x y z) :precision binary64 (if (<= z -440000000000.0) (- x z) (if (<= z 9500.0) (+ x (* y (- 1.0 (log y)))) (- x z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -440000000000.0) {
tmp = x - z;
} else if (z <= 9500.0) {
tmp = x + (y * (1.0 - log(y)));
} 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 (z <= (-440000000000.0d0)) then
tmp = x - z
else if (z <= 9500.0d0) then
tmp = x + (y * (1.0d0 - log(y)))
else
tmp = x - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -440000000000.0) {
tmp = x - z;
} else if (z <= 9500.0) {
tmp = x + (y * (1.0 - Math.log(y)));
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -440000000000.0: tmp = x - z elif z <= 9500.0: tmp = x + (y * (1.0 - math.log(y))) else: tmp = x - z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -440000000000.0) tmp = Float64(x - z); elseif (z <= 9500.0) tmp = Float64(x + Float64(y * Float64(1.0 - log(y)))); else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -440000000000.0) tmp = x - z; elseif (z <= 9500.0) tmp = x + (y * (1.0 - log(y))); else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -440000000000.0], N[(x - z), $MachinePrecision], If[LessEqual[z, 9500.0], N[(x + N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -440000000000:\\
\;\;\;\;x - z\\
\mathbf{elif}\;z \leq 9500:\\
\;\;\;\;x + y \cdot \left(1 - \log y\right)\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if z < -4.4e11 or 9500 < z Initial program 100.0%
associate--l+99.9%
associate-+l-99.9%
Simplified99.9%
Taylor expanded in z around inf 88.2%
if -4.4e11 < z < 9500Initial program 99.7%
associate--l+99.7%
associate-+l-99.7%
Simplified99.7%
Taylor expanded in y around inf 76.0%
sub-neg76.0%
mul-1-neg76.0%
log-rec76.0%
remove-double-neg76.0%
metadata-eval76.0%
Simplified76.0%
Final simplification82.0%
(FPCore (x y z) :precision binary64 (+ x (- (- y z) (* (log y) (+ y 0.5)))))
double code(double x, double y, double z) {
return x + ((y - z) - (log(y) * (y + 0.5)));
}
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 - z) - (log(y) * (y + 0.5d0)))
end function
public static double code(double x, double y, double z) {
return x + ((y - z) - (Math.log(y) * (y + 0.5)));
}
def code(x, y, z): return x + ((y - z) - (math.log(y) * (y + 0.5)))
function code(x, y, z) return Float64(x + Float64(Float64(y - z) - Float64(log(y) * Float64(y + 0.5)))) end
function tmp = code(x, y, z) tmp = x + ((y - z) - (log(y) * (y + 0.5))); end
code[x_, y_, z_] := N[(x + N[(N[(y - z), $MachinePrecision] - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - z\right) - \log y \cdot \left(y + 0.5\right)\right)
\end{array}
Initial program 99.8%
associate--l+99.8%
associate-+l-99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (<= y 3.1e+112) (- (- x (* (log y) 0.5)) z) (+ x (* y (- 1.0 (log y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.1e+112) {
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 <= 3.1d+112) 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 <= 3.1e+112) {
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 <= 3.1e+112: 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 <= 3.1e+112) 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 <= 3.1e+112) 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, 3.1e+112], 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 3.1 \cdot 10^{+112}:\\
\;\;\;\;\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 < 3.09999999999999983e112Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
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 0 94.5%
metadata-eval94.5%
cancel-sign-sub-inv94.5%
*-commutative94.5%
Simplified94.5%
if 3.09999999999999983e112 < y Initial program 99.5%
associate--l+99.5%
associate-+l-99.5%
Simplified99.5%
Taylor expanded in y around inf 75.4%
sub-neg75.4%
mul-1-neg75.4%
log-rec75.4%
remove-double-neg75.4%
metadata-eval75.4%
Simplified75.4%
Final simplification88.3%
(FPCore (x y z) :precision binary64 (if (<= y 2.1e+103) (- (- x (* (log y) 0.5)) z) (- (- y (* y (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.1e+103) {
tmp = (x - (log(y) * 0.5)) - z;
} else {
tmp = (y - (y * log(y))) - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 2.1d+103) then
tmp = (x - (log(y) * 0.5d0)) - z
else
tmp = (y - (y * log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.1e+103) {
tmp = (x - (Math.log(y) * 0.5)) - z;
} else {
tmp = (y - (y * Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.1e+103: tmp = (x - (math.log(y) * 0.5)) - z else: tmp = (y - (y * math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.1e+103) tmp = Float64(Float64(x - Float64(log(y) * 0.5)) - z); else tmp = Float64(Float64(y - Float64(y * log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.1e+103) tmp = (x - (log(y) * 0.5)) - z; else tmp = (y - (y * log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.1e+103], N[(N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(y - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{+103}:\\
\;\;\;\;\left(x - \log y \cdot 0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(y - y \cdot \log y\right) - z\\
\end{array}
\end{array}
if y < 2.1000000000000002e103Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
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 0 94.4%
metadata-eval94.4%
cancel-sign-sub-inv94.4%
*-commutative94.4%
Simplified94.4%
if 2.1000000000000002e103 < y Initial program 99.5%
Taylor expanded in y around inf 86.8%
*-commutative86.8%
log-rec86.8%
distribute-lft-neg-in86.8%
distribute-rgt-neg-in86.8%
Simplified86.8%
Taylor expanded in y around 0 86.9%
mul-1-neg86.9%
log-rec86.9%
distribute-lft-in86.8%
log-rec86.8%
distribute-rgt-neg-in86.8%
unsub-neg86.8%
*-rgt-identity86.8%
Simplified86.8%
Final simplification91.9%
(FPCore (x y z) :precision binary64 (if (<= y 1.55e+165) (- x z) (* y (- 1.0 (log y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.55e+165) {
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 <= 1.55d+165) 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 <= 1.55e+165) {
tmp = x - z;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.55e+165: tmp = x - z else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.55e+165) 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 <= 1.55e+165) tmp = x - z; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.55e+165], 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 1.55 \cdot 10^{+165}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 1.5500000000000001e165Initial program 99.9%
associate--l+99.9%
associate-+l-99.9%
Simplified99.9%
Taylor expanded in z around inf 74.9%
if 1.5500000000000001e165 < y Initial program 99.4%
associate--l+99.4%
associate-+l-99.4%
Simplified99.4%
Taylor expanded in z around 0 77.3%
Taylor expanded in y around inf 71.0%
mul-1-neg71.0%
log-rec71.0%
remove-double-neg71.0%
Simplified71.0%
Final simplification74.0%
(FPCore (x y z) :precision binary64 (if (<= z -8.6e+57) (- z) (if (<= z 3.1e+65) x (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -8.6e+57) {
tmp = -z;
} else if (z <= 3.1e+65) {
tmp = x;
} else {
tmp = -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 (z <= (-8.6d+57)) then
tmp = -z
else if (z <= 3.1d+65) then
tmp = x
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -8.6e+57) {
tmp = -z;
} else if (z <= 3.1e+65) {
tmp = x;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -8.6e+57: tmp = -z elif z <= 3.1e+65: tmp = x else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -8.6e+57) tmp = Float64(-z); elseif (z <= 3.1e+65) tmp = x; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -8.6e+57) tmp = -z; elseif (z <= 3.1e+65) tmp = x; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -8.6e+57], (-z), If[LessEqual[z, 3.1e+65], x, (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.6 \cdot 10^{+57}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 3.1 \cdot 10^{+65}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -8.60000000000000066e57 or 3.09999999999999991e65 < z Initial program 99.9%
add-cube-cbrt99.3%
pow399.4%
sub-neg99.4%
*-commutative99.4%
distribute-rgt-neg-in99.4%
+-commutative99.4%
distribute-neg-in99.4%
metadata-eval99.4%
sub-neg99.4%
Applied egg-rr99.4%
Taylor expanded in z around inf 72.7%
neg-mul-172.7%
Simplified72.7%
if -8.60000000000000066e57 < z < 3.09999999999999991e65Initial program 99.7%
associate--l+99.7%
sub-neg99.7%
associate-+l+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 x around inf 41.1%
Final simplification54.1%
(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%
associate-+l-99.8%
Simplified99.8%
Taylor expanded in z around inf 63.8%
Final simplification63.8%
(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 31.7%
Final simplification31.7%
(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 2023293
(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))