
(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 + 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-define99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (* y (- 1.0 (log y))))) (t_1 (- y (* (log y) (+ y 0.5)))))
(if (<= z -80.0)
(- x z)
(if (<= z -6e-111)
t_1
(if (<= z -1.45e-151)
t_0
(if (<= z -1.4e-190) t_1 (if (<= z 4e+104) t_0 (- x z))))))))
double code(double x, double y, double z) {
double t_0 = x + (y * (1.0 - log(y)));
double t_1 = y - (log(y) * (y + 0.5));
double tmp;
if (z <= -80.0) {
tmp = x - z;
} else if (z <= -6e-111) {
tmp = t_1;
} else if (z <= -1.45e-151) {
tmp = t_0;
} else if (z <= -1.4e-190) {
tmp = t_1;
} else if (z <= 4e+104) {
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 = x + (y * (1.0d0 - log(y)))
t_1 = y - (log(y) * (y + 0.5d0))
if (z <= (-80.0d0)) then
tmp = x - z
else if (z <= (-6d-111)) then
tmp = t_1
else if (z <= (-1.45d-151)) then
tmp = t_0
else if (z <= (-1.4d-190)) then
tmp = t_1
else if (z <= 4d+104) 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 = x + (y * (1.0 - Math.log(y)));
double t_1 = y - (Math.log(y) * (y + 0.5));
double tmp;
if (z <= -80.0) {
tmp = x - z;
} else if (z <= -6e-111) {
tmp = t_1;
} else if (z <= -1.45e-151) {
tmp = t_0;
} else if (z <= -1.4e-190) {
tmp = t_1;
} else if (z <= 4e+104) {
tmp = t_0;
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): t_0 = x + (y * (1.0 - math.log(y))) t_1 = y - (math.log(y) * (y + 0.5)) tmp = 0 if z <= -80.0: tmp = x - z elif z <= -6e-111: tmp = t_1 elif z <= -1.45e-151: tmp = t_0 elif z <= -1.4e-190: tmp = t_1 elif z <= 4e+104: tmp = t_0 else: tmp = x - z return tmp
function code(x, y, z) t_0 = Float64(x + Float64(y * Float64(1.0 - log(y)))) t_1 = Float64(y - Float64(log(y) * Float64(y + 0.5))) tmp = 0.0 if (z <= -80.0) tmp = Float64(x - z); elseif (z <= -6e-111) tmp = t_1; elseif (z <= -1.45e-151) tmp = t_0; elseif (z <= -1.4e-190) tmp = t_1; elseif (z <= 4e+104) tmp = t_0; else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + (y * (1.0 - log(y))); t_1 = y - (log(y) * (y + 0.5)); tmp = 0.0; if (z <= -80.0) tmp = x - z; elseif (z <= -6e-111) tmp = t_1; elseif (z <= -1.45e-151) tmp = t_0; elseif (z <= -1.4e-190) tmp = t_1; elseif (z <= 4e+104) tmp = t_0; else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -80.0], N[(x - z), $MachinePrecision], If[LessEqual[z, -6e-111], t$95$1, If[LessEqual[z, -1.45e-151], t$95$0, If[LessEqual[z, -1.4e-190], t$95$1, If[LessEqual[z, 4e+104], t$95$0, N[(x - z), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + y \cdot \left(1 - \log y\right)\\
t_1 := y - \log y \cdot \left(y + 0.5\right)\\
\mathbf{if}\;z \leq -80:\\
\;\;\;\;x - z\\
\mathbf{elif}\;z \leq -6 \cdot 10^{-111}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -1.45 \cdot 10^{-151}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.4 \cdot 10^{-190}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 4 \cdot 10^{+104}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if z < -80 or 4e104 < z Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
associate-+l+99.9%
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 y around inf 99.4%
log-rec99.4%
sub-neg99.4%
Simplified99.4%
Taylor expanded in y around 0 85.7%
if -80 < z < -6.00000000000000016e-111 or -1.45000000000000006e-151 < z < -1.40000000000000003e-190Initial program 99.6%
associate--l+99.6%
sub-neg99.6%
associate-+l+99.6%
associate-+r-99.6%
*-commutative99.6%
distribute-rgt-neg-in99.6%
fma-define99.6%
+-commutative99.6%
distribute-neg-in99.6%
unsub-neg99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around 0 90.4%
mul-1-neg90.4%
sub-neg90.4%
associate--l+90.4%
+-commutative90.4%
+-commutative90.4%
associate--l+90.4%
Simplified90.4%
Taylor expanded in x around 0 81.3%
+-commutative81.3%
Simplified81.3%
if -6.00000000000000016e-111 < z < -1.45000000000000006e-151 or -1.40000000000000003e-190 < z < 4e104Initial 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-define99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 84.3%
log-rec84.3%
sub-neg84.3%
Simplified84.3%
Taylor expanded in z around 0 80.5%
Final simplification82.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* y (log (/ E y))) z)) (t_1 (- y (* (log y) (+ y 0.5)))))
(if (<= x -1.55e+111)
(+ x (* y (- 1.0 (log y))))
(if (<= x -8.5e-272)
t_0
(if (<= x 1.6e-288)
t_1
(if (<= x 9e-145) t_0 (if (<= x 4700000000000.0) t_1 (- x z))))))))
double code(double x, double y, double z) {
double t_0 = (y * log((((double) M_E) / y))) - z;
double t_1 = y - (log(y) * (y + 0.5));
double tmp;
if (x <= -1.55e+111) {
tmp = x + (y * (1.0 - log(y)));
} else if (x <= -8.5e-272) {
tmp = t_0;
} else if (x <= 1.6e-288) {
tmp = t_1;
} else if (x <= 9e-145) {
tmp = t_0;
} else if (x <= 4700000000000.0) {
tmp = t_1;
} else {
tmp = x - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = (y * Math.log((Math.E / y))) - z;
double t_1 = y - (Math.log(y) * (y + 0.5));
double tmp;
if (x <= -1.55e+111) {
tmp = x + (y * (1.0 - Math.log(y)));
} else if (x <= -8.5e-272) {
tmp = t_0;
} else if (x <= 1.6e-288) {
tmp = t_1;
} else if (x <= 9e-145) {
tmp = t_0;
} else if (x <= 4700000000000.0) {
tmp = t_1;
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): t_0 = (y * math.log((math.e / y))) - z t_1 = y - (math.log(y) * (y + 0.5)) tmp = 0 if x <= -1.55e+111: tmp = x + (y * (1.0 - math.log(y))) elif x <= -8.5e-272: tmp = t_0 elif x <= 1.6e-288: tmp = t_1 elif x <= 9e-145: tmp = t_0 elif x <= 4700000000000.0: tmp = t_1 else: tmp = x - z return tmp
function code(x, y, z) t_0 = Float64(Float64(y * log(Float64(exp(1) / y))) - z) t_1 = Float64(y - Float64(log(y) * Float64(y + 0.5))) tmp = 0.0 if (x <= -1.55e+111) tmp = Float64(x + Float64(y * Float64(1.0 - log(y)))); elseif (x <= -8.5e-272) tmp = t_0; elseif (x <= 1.6e-288) tmp = t_1; elseif (x <= 9e-145) tmp = t_0; elseif (x <= 4700000000000.0) tmp = t_1; else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y * log((2.71828182845904523536 / y))) - z; t_1 = y - (log(y) * (y + 0.5)); tmp = 0.0; if (x <= -1.55e+111) tmp = x + (y * (1.0 - log(y))); elseif (x <= -8.5e-272) tmp = t_0; elseif (x <= 1.6e-288) tmp = t_1; elseif (x <= 9e-145) tmp = t_0; elseif (x <= 4700000000000.0) tmp = t_1; else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y * N[Log[N[(E / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(y - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.55e+111], N[(x + N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -8.5e-272], t$95$0, If[LessEqual[x, 1.6e-288], t$95$1, If[LessEqual[x, 9e-145], t$95$0, If[LessEqual[x, 4700000000000.0], t$95$1, N[(x - z), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \log \left(\frac{e}{y}\right) - z\\
t_1 := y - \log y \cdot \left(y + 0.5\right)\\
\mathbf{if}\;x \leq -1.55 \cdot 10^{+111}:\\
\;\;\;\;x + y \cdot \left(1 - \log y\right)\\
\mathbf{elif}\;x \leq -8.5 \cdot 10^{-272}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-288}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-145}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4700000000000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if x < -1.55e111Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
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 y around inf 100.0%
log-rec100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 92.6%
if -1.55e111 < x < -8.5000000000000001e-272 or 1.6e-288 < x < 9.0000000000000001e-145Initial program 99.8%
add-cube-cbrt98.8%
pow398.8%
sub-neg98.8%
*-commutative98.8%
distribute-rgt-neg-in98.8%
+-commutative98.8%
distribute-neg-in98.8%
metadata-eval98.8%
sub-neg98.8%
Applied egg-rr98.8%
Taylor expanded in y around inf 79.0%
log-rec79.0%
neg-mul-179.0%
neg-mul-179.0%
sub-neg79.0%
Simplified79.0%
add-log-exp79.0%
exp-diff79.0%
add-exp-log79.0%
Applied egg-rr79.0%
exp-1-e79.0%
Simplified79.0%
if -8.5000000000000001e-272 < x < 1.6e-288 or 9.0000000000000001e-145 < x < 4.7e12Initial program 99.6%
associate--l+99.6%
sub-neg99.6%
associate-+l+99.6%
associate-+r-99.6%
*-commutative99.6%
distribute-rgt-neg-in99.6%
fma-define99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 88.4%
mul-1-neg88.4%
sub-neg88.4%
associate--l+88.4%
+-commutative88.4%
+-commutative88.4%
associate--l+88.4%
Simplified88.4%
Taylor expanded in x around 0 88.4%
+-commutative88.4%
Simplified88.4%
if 4.7e12 < 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-define99.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 83.4%
Final simplification83.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (* y (- 1.0 (log y))))))
(if (<= y 45000.0)
(- (- x (* (log y) 0.5)) z)
(if (<= y 1.16e+29)
t_0
(if (<= y 4.9e+48)
(- x z)
(if (<= y 9.5e+123) t_0 (- (* y (log (/ E y))) z)))))))
double code(double x, double y, double z) {
double t_0 = x + (y * (1.0 - log(y)));
double tmp;
if (y <= 45000.0) {
tmp = (x - (log(y) * 0.5)) - z;
} else if (y <= 1.16e+29) {
tmp = t_0;
} else if (y <= 4.9e+48) {
tmp = x - z;
} else if (y <= 9.5e+123) {
tmp = t_0;
} else {
tmp = (y * log((((double) M_E) / y))) - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x + (y * (1.0 - Math.log(y)));
double tmp;
if (y <= 45000.0) {
tmp = (x - (Math.log(y) * 0.5)) - z;
} else if (y <= 1.16e+29) {
tmp = t_0;
} else if (y <= 4.9e+48) {
tmp = x - z;
} else if (y <= 9.5e+123) {
tmp = t_0;
} else {
tmp = (y * Math.log((Math.E / y))) - z;
}
return tmp;
}
def code(x, y, z): t_0 = x + (y * (1.0 - math.log(y))) tmp = 0 if y <= 45000.0: tmp = (x - (math.log(y) * 0.5)) - z elif y <= 1.16e+29: tmp = t_0 elif y <= 4.9e+48: tmp = x - z elif y <= 9.5e+123: tmp = t_0 else: tmp = (y * math.log((math.e / y))) - z return tmp
function code(x, y, z) t_0 = Float64(x + Float64(y * Float64(1.0 - log(y)))) tmp = 0.0 if (y <= 45000.0) tmp = Float64(Float64(x - Float64(log(y) * 0.5)) - z); elseif (y <= 1.16e+29) tmp = t_0; elseif (y <= 4.9e+48) tmp = Float64(x - z); elseif (y <= 9.5e+123) tmp = t_0; else tmp = Float64(Float64(y * log(Float64(exp(1) / y))) - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + (y * (1.0 - log(y))); tmp = 0.0; if (y <= 45000.0) tmp = (x - (log(y) * 0.5)) - z; elseif (y <= 1.16e+29) tmp = t_0; elseif (y <= 4.9e+48) tmp = x - z; elseif (y <= 9.5e+123) tmp = t_0; else tmp = (y * log((2.71828182845904523536 / y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 45000.0], N[(N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[y, 1.16e+29], t$95$0, If[LessEqual[y, 4.9e+48], N[(x - z), $MachinePrecision], If[LessEqual[y, 9.5e+123], t$95$0, N[(N[(y * N[Log[N[(E / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + y \cdot \left(1 - \log y\right)\\
\mathbf{if}\;y \leq 45000:\\
\;\;\;\;\left(x - \log y \cdot 0.5\right) - z\\
\mathbf{elif}\;y \leq 1.16 \cdot 10^{+29}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.9 \cdot 10^{+48}:\\
\;\;\;\;x - z\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{+123}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot \log \left(\frac{e}{y}\right) - z\\
\end{array}
\end{array}
if y < 45000Initial program 100.0%
Taylor expanded in y around 0 100.0%
if 45000 < y < 1.16e29 or 4.9000000000000003e48 < y < 9.4999999999999996e123Initial program 99.5%
associate--l+99.5%
sub-neg99.5%
associate-+l+99.5%
associate-+r-99.5%
*-commutative99.5%
distribute-rgt-neg-in99.5%
fma-define99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 96.5%
log-rec96.5%
sub-neg96.5%
Simplified96.5%
Taylor expanded in z around 0 84.9%
if 1.16e29 < y < 4.9000000000000003e48Initial 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 y around inf 100.0%
log-rec100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
if 9.4999999999999996e123 < y Initial program 99.6%
add-cube-cbrt98.4%
pow398.3%
sub-neg98.3%
*-commutative98.3%
distribute-rgt-neg-in98.3%
+-commutative98.3%
distribute-neg-in98.3%
metadata-eval98.3%
sub-neg98.3%
Applied egg-rr98.3%
Taylor expanded in y around inf 91.9%
log-rec91.9%
neg-mul-191.9%
neg-mul-191.9%
sub-neg91.9%
Simplified91.9%
add-log-exp91.9%
exp-diff91.9%
add-exp-log91.9%
Applied egg-rr91.9%
exp-1-e91.9%
Simplified91.9%
Final simplification95.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.05e+68) (not (<= z 1.2e+106))) (- x z) (+ x (* y (- 1.0 (log y))))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.05e+68) || !(z <= 1.2e+106)) {
tmp = x - z;
} else {
tmp = x + (y * (1.0 - log(y)));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-2.05d+68)) .or. (.not. (z <= 1.2d+106))) then
tmp = x - z
else
tmp = x + (y * (1.0d0 - log(y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.05e+68) || !(z <= 1.2e+106)) {
tmp = x - z;
} else {
tmp = x + (y * (1.0 - Math.log(y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.05e+68) or not (z <= 1.2e+106): tmp = x - z else: tmp = x + (y * (1.0 - math.log(y))) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.05e+68) || !(z <= 1.2e+106)) tmp = Float64(x - z); else tmp = Float64(x + Float64(y * Float64(1.0 - log(y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.05e+68) || ~((z <= 1.2e+106))) tmp = x - z; else tmp = x + (y * (1.0 - log(y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.05e+68], N[Not[LessEqual[z, 1.2e+106]], $MachinePrecision]], N[(x - z), $MachinePrecision], N[(x + N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.05 \cdot 10^{+68} \lor \neg \left(z \leq 1.2 \cdot 10^{+106}\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if z < -2.05e68 or 1.2e106 < z Initial program 100.0%
associate--l+99.9%
sub-neg99.9%
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 y around inf 100.0%
log-rec100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 88.5%
if -2.05e68 < z < 1.2e106Initial 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-define99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 79.9%
log-rec79.9%
sub-neg79.9%
Simplified79.9%
Taylor expanded in z around 0 75.0%
Final simplification79.1%
(FPCore (x y z) :precision binary64 (if (<= y 2.7e-10) (- (- 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 <= 2.7e-10) {
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 <= 2.7d-10) 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 <= 2.7e-10) {
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 <= 2.7e-10: 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 <= 2.7e-10) 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 <= 2.7e-10) 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, 2.7e-10], 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 2.7 \cdot 10^{-10}:\\
\;\;\;\;\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 < 2.7e-10Initial program 100.0%
Taylor expanded in y around 0 100.0%
if 2.7e-10 < y Initial program 99.6%
associate--l+99.6%
sub-neg99.6%
associate-+l+99.6%
associate-+r-99.6%
*-commutative99.6%
distribute-rgt-neg-in99.6%
fma-define99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 98.6%
log-rec98.6%
sub-neg98.6%
Simplified98.6%
Final simplification99.3%
(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 (<= y 4.6e+50) (- (+ x y) z) (* y (- 1.0 (log y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.6e+50) {
tmp = (x + 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 <= 4.6d+50) then
tmp = (x + 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 <= 4.6e+50) {
tmp = (x + y) - z;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4.6e+50: tmp = (x + y) - z else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4.6e+50) tmp = Float64(Float64(x + 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 <= 4.6e+50) tmp = (x + y) - z; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4.6e+50], N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.6 \cdot 10^{+50}:\\
\;\;\;\;\left(x + y\right) - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 4.59999999999999994e50Initial program 99.9%
add-cube-cbrt98.5%
pow398.5%
sub-neg98.5%
*-commutative98.5%
distribute-rgt-neg-in98.5%
+-commutative98.5%
distribute-neg-in98.5%
metadata-eval98.5%
sub-neg98.5%
Applied egg-rr98.5%
Taylor expanded in x around inf 71.7%
if 4.59999999999999994e50 < y Initial program 99.6%
associate--l+99.6%
sub-neg99.6%
associate-+l+99.6%
associate-+r-99.6%
*-commutative99.6%
distribute-rgt-neg-in99.6%
fma-define99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 83.8%
mul-1-neg83.8%
sub-neg83.8%
associate--l+83.8%
+-commutative83.8%
+-commutative83.8%
associate--l+83.8%
Simplified83.8%
Taylor expanded in y around inf 70.9%
mul-1-neg70.9%
log-rec70.9%
remove-double-neg70.9%
Simplified70.9%
Final simplification71.4%
(FPCore (x y z) :precision binary64 (if (<= x -8.2e+102) x (if (<= x 3.4e+157) (- z) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -8.2e+102) {
tmp = x;
} else if (x <= 3.4e+157) {
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 <= (-8.2d+102)) then
tmp = x
else if (x <= 3.4d+157) 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 <= -8.2e+102) {
tmp = x;
} else if (x <= 3.4e+157) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -8.2e+102: tmp = x elif x <= 3.4e+157: tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -8.2e+102) tmp = x; elseif (x <= 3.4e+157) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -8.2e+102) tmp = x; elseif (x <= 3.4e+157) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -8.2e+102], x, If[LessEqual[x, 3.4e+157], (-z), x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{+102}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{+157}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -8.1999999999999999e102 or 3.39999999999999979e157 < x Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
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 x around inf 82.2%
if -8.1999999999999999e102 < x < 3.39999999999999979e157Initial program 99.8%
add-cube-cbrt98.7%
pow398.6%
sub-neg98.6%
*-commutative98.6%
distribute-rgt-neg-in98.6%
+-commutative98.6%
distribute-neg-in98.6%
metadata-eval98.6%
sub-neg98.6%
Applied egg-rr98.6%
Taylor expanded in y around inf 72.9%
log-rec72.9%
neg-mul-172.9%
neg-mul-172.9%
sub-neg72.9%
Simplified72.9%
Taylor expanded in y around 0 33.3%
neg-mul-133.3%
Simplified33.3%
Final simplification47.4%
(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-define99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 85.9%
log-rec85.9%
sub-neg85.9%
Simplified85.9%
Taylor expanded in y around 0 54.5%
Final simplification54.5%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.8%
associate--l+99.8%
sub-neg99.8%
associate-+l+99.8%
associate-+r-99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around inf 30.6%
Final simplification30.6%
(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 2024082
(FPCore (x y z)
:name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
:precision binary64
:alt
(- (- (+ y x) z) (* (+ y 0.5) (log y)))
(- (+ (- x (* (+ y 0.5) (log y))) y) z))