
(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 13 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.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (- 1.0 (log y)))) (t_1 (+ x t_0)))
(if (<= z -1.6e+119)
(- t_0 z)
(if (<= z -2600000000000.0)
(- x z)
(if (<= z -3.8e-103)
t_1
(if (<= z -3.6e-138)
(- y (* (log y) (+ y 0.5)))
(if (<= z 2.3e+57) t_1 (- x z))))))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - log(y));
double t_1 = x + t_0;
double tmp;
if (z <= -1.6e+119) {
tmp = t_0 - z;
} else if (z <= -2600000000000.0) {
tmp = x - z;
} else if (z <= -3.8e-103) {
tmp = t_1;
} else if (z <= -3.6e-138) {
tmp = y - (log(y) * (y + 0.5));
} else if (z <= 2.3e+57) {
tmp = t_1;
} 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 + t_0
if (z <= (-1.6d+119)) then
tmp = t_0 - z
else if (z <= (-2600000000000.0d0)) then
tmp = x - z
else if (z <= (-3.8d-103)) then
tmp = t_1
else if (z <= (-3.6d-138)) then
tmp = y - (log(y) * (y + 0.5d0))
else if (z <= 2.3d+57) then
tmp = t_1
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 + t_0;
double tmp;
if (z <= -1.6e+119) {
tmp = t_0 - z;
} else if (z <= -2600000000000.0) {
tmp = x - z;
} else if (z <= -3.8e-103) {
tmp = t_1;
} else if (z <= -3.6e-138) {
tmp = y - (Math.log(y) * (y + 0.5));
} else if (z <= 2.3e+57) {
tmp = t_1;
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 - math.log(y)) t_1 = x + t_0 tmp = 0 if z <= -1.6e+119: tmp = t_0 - z elif z <= -2600000000000.0: tmp = x - z elif z <= -3.8e-103: tmp = t_1 elif z <= -3.6e-138: tmp = y - (math.log(y) * (y + 0.5)) elif z <= 2.3e+57: tmp = t_1 else: tmp = x - z return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - log(y))) t_1 = Float64(x + t_0) tmp = 0.0 if (z <= -1.6e+119) tmp = Float64(t_0 - z); elseif (z <= -2600000000000.0) tmp = Float64(x - z); elseif (z <= -3.8e-103) tmp = t_1; elseif (z <= -3.6e-138) tmp = Float64(y - Float64(log(y) * Float64(y + 0.5))); elseif (z <= 2.3e+57) tmp = t_1; 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 + t_0; tmp = 0.0; if (z <= -1.6e+119) tmp = t_0 - z; elseif (z <= -2600000000000.0) tmp = x - z; elseif (z <= -3.8e-103) tmp = t_1; elseif (z <= -3.6e-138) tmp = y - (log(y) * (y + 0.5)); elseif (z <= 2.3e+57) tmp = t_1; 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 + t$95$0), $MachinePrecision]}, If[LessEqual[z, -1.6e+119], N[(t$95$0 - z), $MachinePrecision], If[LessEqual[z, -2600000000000.0], N[(x - z), $MachinePrecision], If[LessEqual[z, -3.8e-103], t$95$1, If[LessEqual[z, -3.6e-138], N[(y - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.3e+57], t$95$1, N[(x - z), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - \log y\right)\\
t_1 := x + t\_0\\
\mathbf{if}\;z \leq -1.6 \cdot 10^{+119}:\\
\;\;\;\;t\_0 - z\\
\mathbf{elif}\;z \leq -2600000000000:\\
\;\;\;\;x - z\\
\mathbf{elif}\;z \leq -3.8 \cdot 10^{-103}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -3.6 \cdot 10^{-138}:\\
\;\;\;\;y - \log y \cdot \left(y + 0.5\right)\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{+57}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if z < -1.59999999999999995e119Initial 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 x around 0 91.2%
if -1.59999999999999995e119 < z < -2.6e12 or 2.2999999999999999e57 < z Initial 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 99.4%
log-rec99.4%
sub-neg99.4%
Simplified99.4%
Taylor expanded in y around 0 94.3%
if -2.6e12 < z < -3.8000000000000001e-103 or -3.60000000000000018e-138 < z < 2.2999999999999999e57Initial 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.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 80.6%
log-rec80.6%
sub-neg80.6%
Simplified80.6%
Taylor expanded in z around 0 79.5%
+-commutative79.5%
Simplified79.5%
if -3.8000000000000001e-103 < z < -3.60000000000000018e-138Initial program 99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in z around 0 99.7%
Taylor expanded in x around 0 98.1%
+-commutative98.1%
Simplified98.1%
Final simplification86.0%
(FPCore (x y z)
:precision binary64
(if (<= y 3.6e-248)
(- x z)
(if (<= y 4.4e-209)
(- x (* (log y) 0.5))
(if (or (<= y 2.85e+137) (and (not (<= y 1.35e+174)) (<= y 9e+183)))
(- x z)
(- y (* y (log y)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.6e-248) {
tmp = x - z;
} else if (y <= 4.4e-209) {
tmp = x - (log(y) * 0.5);
} else if ((y <= 2.85e+137) || (!(y <= 1.35e+174) && (y <= 9e+183))) {
tmp = x - z;
} else {
tmp = y - (y * 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.6d-248) then
tmp = x - z
else if (y <= 4.4d-209) then
tmp = x - (log(y) * 0.5d0)
else if ((y <= 2.85d+137) .or. (.not. (y <= 1.35d+174)) .and. (y <= 9d+183)) then
tmp = x - z
else
tmp = y - (y * log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3.6e-248) {
tmp = x - z;
} else if (y <= 4.4e-209) {
tmp = x - (Math.log(y) * 0.5);
} else if ((y <= 2.85e+137) || (!(y <= 1.35e+174) && (y <= 9e+183))) {
tmp = x - z;
} else {
tmp = y - (y * Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.6e-248: tmp = x - z elif y <= 4.4e-209: tmp = x - (math.log(y) * 0.5) elif (y <= 2.85e+137) or (not (y <= 1.35e+174) and (y <= 9e+183)): tmp = x - z else: tmp = y - (y * math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.6e-248) tmp = Float64(x - z); elseif (y <= 4.4e-209) tmp = Float64(x - Float64(log(y) * 0.5)); elseif ((y <= 2.85e+137) || (!(y <= 1.35e+174) && (y <= 9e+183))) tmp = Float64(x - z); else tmp = Float64(y - Float64(y * log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.6e-248) tmp = x - z; elseif (y <= 4.4e-209) tmp = x - (log(y) * 0.5); elseif ((y <= 2.85e+137) || (~((y <= 1.35e+174)) && (y <= 9e+183))) tmp = x - z; else tmp = y - (y * log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.6e-248], N[(x - z), $MachinePrecision], If[LessEqual[y, 4.4e-209], N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 2.85e+137], And[N[Not[LessEqual[y, 1.35e+174]], $MachinePrecision], LessEqual[y, 9e+183]]], N[(x - z), $MachinePrecision], N[(y - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.6 \cdot 10^{-248}:\\
\;\;\;\;x - z\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{-209}:\\
\;\;\;\;x - \log y \cdot 0.5\\
\mathbf{elif}\;y \leq 2.85 \cdot 10^{+137} \lor \neg \left(y \leq 1.35 \cdot 10^{+174}\right) \land y \leq 9 \cdot 10^{+183}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;y - y \cdot \log y\\
\end{array}
\end{array}
if y < 3.59999999999999985e-248 or 4.40000000000000019e-209 < y < 2.8499999999999999e137 or 1.35e174 < y < 9.00000000000000034e183Initial 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 86.4%
log-rec86.4%
sub-neg86.4%
Simplified86.4%
Taylor expanded in y around 0 73.9%
if 3.59999999999999985e-248 < y < 4.40000000000000019e-209Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in z around 0 82.9%
Taylor expanded in y around 0 82.9%
if 2.8499999999999999e137 < y < 1.35e174 or 9.00000000000000034e183 < y Initial program 99.5%
Taylor expanded in y around inf 91.1%
*-commutative91.1%
log-rec91.1%
distribute-lft-neg-in91.1%
distribute-rgt-neg-in91.1%
Simplified91.1%
Taylor expanded in z around 0 77.9%
Final simplification75.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (* y (- 1.0 (log y))))))
(if (<= z -700000000000.0)
(- x z)
(if (<= z -3.8e-103)
t_0
(if (<= z -3e-138)
(- y (* (log y) (+ y 0.5)))
(if (<= z 7e+56) t_0 (- x z)))))))
double code(double x, double y, double z) {
double t_0 = x + (y * (1.0 - log(y)));
double tmp;
if (z <= -700000000000.0) {
tmp = x - z;
} else if (z <= -3.8e-103) {
tmp = t_0;
} else if (z <= -3e-138) {
tmp = y - (log(y) * (y + 0.5));
} else if (z <= 7e+56) {
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 = x + (y * (1.0d0 - log(y)))
if (z <= (-700000000000.0d0)) then
tmp = x - z
else if (z <= (-3.8d-103)) then
tmp = t_0
else if (z <= (-3d-138)) then
tmp = y - (log(y) * (y + 0.5d0))
else if (z <= 7d+56) 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 tmp;
if (z <= -700000000000.0) {
tmp = x - z;
} else if (z <= -3.8e-103) {
tmp = t_0;
} else if (z <= -3e-138) {
tmp = y - (Math.log(y) * (y + 0.5));
} else if (z <= 7e+56) {
tmp = t_0;
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): t_0 = x + (y * (1.0 - math.log(y))) tmp = 0 if z <= -700000000000.0: tmp = x - z elif z <= -3.8e-103: tmp = t_0 elif z <= -3e-138: tmp = y - (math.log(y) * (y + 0.5)) elif z <= 7e+56: 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)))) tmp = 0.0 if (z <= -700000000000.0) tmp = Float64(x - z); elseif (z <= -3.8e-103) tmp = t_0; elseif (z <= -3e-138) tmp = Float64(y - Float64(log(y) * Float64(y + 0.5))); elseif (z <= 7e+56) 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))); tmp = 0.0; if (z <= -700000000000.0) tmp = x - z; elseif (z <= -3.8e-103) tmp = t_0; elseif (z <= -3e-138) tmp = y - (log(y) * (y + 0.5)); elseif (z <= 7e+56) 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]}, If[LessEqual[z, -700000000000.0], N[(x - z), $MachinePrecision], If[LessEqual[z, -3.8e-103], t$95$0, If[LessEqual[z, -3e-138], N[(y - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7e+56], t$95$0, N[(x - z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + y \cdot \left(1 - \log y\right)\\
\mathbf{if}\;z \leq -700000000000:\\
\;\;\;\;x - z\\
\mathbf{elif}\;z \leq -3.8 \cdot 10^{-103}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -3 \cdot 10^{-138}:\\
\;\;\;\;y - \log y \cdot \left(y + 0.5\right)\\
\mathbf{elif}\;z \leq 7 \cdot 10^{+56}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if z < -7e11 or 6.99999999999999999e56 < z Initial 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 99.6%
log-rec99.6%
sub-neg99.6%
Simplified99.6%
Taylor expanded in y around 0 87.5%
if -7e11 < z < -3.8000000000000001e-103 or -3.0000000000000001e-138 < z < 6.99999999999999999e56Initial 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.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 80.6%
log-rec80.6%
sub-neg80.6%
Simplified80.6%
Taylor expanded in z around 0 79.5%
+-commutative79.5%
Simplified79.5%
if -3.8000000000000001e-103 < z < -3.0000000000000001e-138Initial program 99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in z around 0 99.7%
Taylor expanded in x around 0 98.1%
+-commutative98.1%
Simplified98.1%
Final simplification83.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -2600000000000.0) (not (<= z 6.5e+57))) (- x z) (+ x (* y (- 1.0 (log y))))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2600000000000.0) || !(z <= 6.5e+57)) {
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 <= (-2600000000000.0d0)) .or. (.not. (z <= 6.5d+57))) 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 <= -2600000000000.0) || !(z <= 6.5e+57)) {
tmp = x - z;
} else {
tmp = x + (y * (1.0 - Math.log(y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2600000000000.0) or not (z <= 6.5e+57): tmp = x - z else: tmp = x + (y * (1.0 - math.log(y))) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2600000000000.0) || !(z <= 6.5e+57)) 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 <= -2600000000000.0) || ~((z <= 6.5e+57))) tmp = x - z; else tmp = x + (y * (1.0 - log(y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2600000000000.0], N[Not[LessEqual[z, 6.5e+57]], $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 -2600000000000 \lor \neg \left(z \leq 6.5 \cdot 10^{+57}\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if z < -2.6e12 or 6.4999999999999997e57 < z Initial 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 99.6%
log-rec99.6%
sub-neg99.6%
Simplified99.6%
Taylor expanded in y around 0 87.5%
if -2.6e12 < z < 6.4999999999999997e57Initial 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.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 78.7%
log-rec78.7%
sub-neg78.7%
Simplified78.7%
Taylor expanded in z around 0 77.7%
+-commutative77.7%
Simplified77.7%
Final simplification81.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (- 1.0 (log y)))))
(if (<= y 0.0019)
(- (+ x (* (log y) -0.5)) z)
(if (<= y 4.2e+183) (+ x t_0) (- t_0 z)))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - log(y));
double tmp;
if (y <= 0.0019) {
tmp = (x + (log(y) * -0.5)) - z;
} else if (y <= 4.2e+183) {
tmp = x + t_0;
} else {
tmp = t_0 - 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 = y * (1.0d0 - log(y))
if (y <= 0.0019d0) then
tmp = (x + (log(y) * (-0.5d0))) - z
else if (y <= 4.2d+183) then
tmp = x + t_0
else
tmp = t_0 - 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 tmp;
if (y <= 0.0019) {
tmp = (x + (Math.log(y) * -0.5)) - z;
} else if (y <= 4.2e+183) {
tmp = x + t_0;
} else {
tmp = t_0 - z;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 - math.log(y)) tmp = 0 if y <= 0.0019: tmp = (x + (math.log(y) * -0.5)) - z elif y <= 4.2e+183: tmp = x + t_0 else: tmp = t_0 - z return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - log(y))) tmp = 0.0 if (y <= 0.0019) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z); elseif (y <= 4.2e+183) tmp = Float64(x + t_0); else tmp = Float64(t_0 - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 - log(y)); tmp = 0.0; if (y <= 0.0019) tmp = (x + (log(y) * -0.5)) - z; elseif (y <= 4.2e+183) tmp = x + t_0; else tmp = t_0 - 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]}, If[LessEqual[y, 0.0019], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[y, 4.2e+183], N[(x + t$95$0), $MachinePrecision], N[(t$95$0 - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - \log y\right)\\
\mathbf{if}\;y \leq 0.0019:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{+183}:\\
\;\;\;\;x + t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if y < 0.0019Initial 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 0 99.8%
+-commutative99.8%
Simplified99.8%
if 0.0019 < y < 4.2e183Initial 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.2%
log-rec99.2%
sub-neg99.2%
Simplified99.2%
Taylor expanded in z around 0 77.4%
+-commutative77.4%
Simplified77.4%
if 4.2e183 < y Initial program 99.4%
associate--l+99.4%
sub-neg99.4%
associate-+l+99.4%
associate-+r-99.4%
*-commutative99.4%
distribute-rgt-neg-in99.4%
fma-define99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 99.7%
log-rec99.7%
sub-neg99.7%
Simplified99.7%
Taylor expanded in x around 0 94.4%
Final simplification91.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -8500.0) (not (<= x 360000000.0))) (- x z) (- (* (log y) -0.5) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8500.0) || !(x <= 360000000.0)) {
tmp = x - z;
} else {
tmp = (log(y) * -0.5) - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-8500.0d0)) .or. (.not. (x <= 360000000.0d0))) then
tmp = x - z
else
tmp = (log(y) * (-0.5d0)) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -8500.0) || !(x <= 360000000.0)) {
tmp = x - z;
} else {
tmp = (Math.log(y) * -0.5) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8500.0) or not (x <= 360000000.0): tmp = x - z else: tmp = (math.log(y) * -0.5) - z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8500.0) || !(x <= 360000000.0)) tmp = Float64(x - z); else tmp = Float64(Float64(log(y) * -0.5) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -8500.0) || ~((x <= 360000000.0))) tmp = x - z; else tmp = (log(y) * -0.5) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8500.0], N[Not[LessEqual[x, 360000000.0]], $MachinePrecision]], N[(x - z), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8500 \lor \neg \left(x \leq 360000000\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\end{array}
\end{array}
if x < -8500 or 3.6e8 < x 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.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 99.3%
log-rec99.3%
sub-neg99.3%
Simplified99.3%
Taylor expanded in y around 0 76.1%
if -8500 < x < 3.6e8Initial 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 0 66.3%
+-commutative66.3%
Simplified66.3%
Taylor expanded in x around 0 66.2%
*-commutative66.2%
Simplified66.2%
Final simplification71.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -14000000000.0) (not (<= z 200.0))) (- x z) (- x (* (log y) 0.5))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -14000000000.0) || !(z <= 200.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 <= (-14000000000.0d0)) .or. (.not. (z <= 200.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 <= -14000000000.0) || !(z <= 200.0)) {
tmp = x - z;
} else {
tmp = x - (Math.log(y) * 0.5);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -14000000000.0) or not (z <= 200.0): tmp = x - z else: tmp = x - (math.log(y) * 0.5) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -14000000000.0) || !(z <= 200.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 <= -14000000000.0) || ~((z <= 200.0))) tmp = x - z; else tmp = x - (log(y) * 0.5); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -14000000000.0], N[Not[LessEqual[z, 200.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 -14000000000 \lor \neg \left(z \leq 200\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;x - \log y \cdot 0.5\\
\end{array}
\end{array}
if z < -1.4e10 or 200 < 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-define100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 99.3%
log-rec99.3%
sub-neg99.3%
Simplified99.3%
Taylor expanded in y around 0 85.4%
if -1.4e10 < z < 200Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in z around 0 99.3%
Taylor expanded in y around 0 58.6%
Final simplification70.7%
(FPCore (x y z) :precision binary64 (if (<= y 0.0019) (- (+ 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 <= 0.0019) {
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 <= 0.0019d0) 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 <= 0.0019) {
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 <= 0.0019: 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 <= 0.0019) 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 <= 0.0019) 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, 0.0019], 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 0.0019:\\
\;\;\;\;\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 < 0.0019Initial 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 0 99.8%
+-commutative99.8%
Simplified99.8%
if 0.0019 < y Initial program 99.7%
associate--l+99.7%
sub-neg99.7%
associate-+l+99.7%
associate-+r-99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
fma-define99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 99.3%
log-rec99.3%
sub-neg99.3%
Simplified99.3%
Final simplification99.6%
(FPCore (x y z) :precision binary64 (+ (- x (* (log y) (+ y 0.5))) (- y z)))
double code(double x, double y, double z) {
return (x - (log(y) * (y + 0.5))) + (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 - (log(y) * (y + 0.5d0))) + (y - z)
end function
public static double code(double x, double y, double z) {
return (x - (Math.log(y) * (y + 0.5))) + (y - z);
}
def code(x, y, z): return (x - (math.log(y) * (y + 0.5))) + (y - z)
function code(x, y, z) return Float64(Float64(x - Float64(log(y) * Float64(y + 0.5))) + Float64(y - z)) end
function tmp = code(x, y, z) tmp = (x - (log(y) * (y + 0.5))) + (y - z); end
code[x_, y_, z_] := N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x - \log y \cdot \left(y + 0.5\right)\right) + \left(y - z\right)
\end{array}
Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.009) (not (<= z 1.7e+19))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.009) || !(z <= 1.7e+19)) {
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 <= (-0.009d0)) .or. (.not. (z <= 1.7d+19))) 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 <= -0.009) || !(z <= 1.7e+19)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.009) or not (z <= 1.7e+19): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.009) || !(z <= 1.7e+19)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.009) || ~((z <= 1.7e+19))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.009], N[Not[LessEqual[z, 1.7e+19]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.009 \lor \neg \left(z \leq 1.7 \cdot 10^{+19}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -0.00899999999999999932 or 1.7e19 < 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-define100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 67.4%
neg-mul-167.4%
Simplified67.4%
if -0.00899999999999999932 < z < 1.7e19Initial 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.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 37.3%
Final simplification50.9%
(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.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 87.6%
log-rec87.6%
sub-neg87.6%
Simplified87.6%
Taylor expanded in y around 0 58.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%
associate-+r-99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
fma-define99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 28.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 2024081
(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))