
(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.9%
associate--l+99.9%
sub-neg99.9%
associate-+l+99.9%
associate-+r-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%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (log y) -0.5) z))
(t_1 (* y (- 1.0 (log y))))
(t_2 (- t_1 z))
(t_3 (+ x t_1)))
(if (<= x -2.4e+139)
t_3
(if (<= x -1.8e-122)
t_2
(if (<= x 1.25e-168)
t_0
(if (<= x 1.55e-114) t_2 (if (<= x 5e-23) t_0 t_3)))))))
double code(double x, double y, double z) {
double t_0 = (log(y) * -0.5) - z;
double t_1 = y * (1.0 - log(y));
double t_2 = t_1 - z;
double t_3 = x + t_1;
double tmp;
if (x <= -2.4e+139) {
tmp = t_3;
} else if (x <= -1.8e-122) {
tmp = t_2;
} else if (x <= 1.25e-168) {
tmp = t_0;
} else if (x <= 1.55e-114) {
tmp = t_2;
} else if (x <= 5e-23) {
tmp = t_0;
} else {
tmp = t_3;
}
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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = (log(y) * (-0.5d0)) - z
t_1 = y * (1.0d0 - log(y))
t_2 = t_1 - z
t_3 = x + t_1
if (x <= (-2.4d+139)) then
tmp = t_3
else if (x <= (-1.8d-122)) then
tmp = t_2
else if (x <= 1.25d-168) then
tmp = t_0
else if (x <= 1.55d-114) then
tmp = t_2
else if (x <= 5d-23) then
tmp = t_0
else
tmp = t_3
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (Math.log(y) * -0.5) - z;
double t_1 = y * (1.0 - Math.log(y));
double t_2 = t_1 - z;
double t_3 = x + t_1;
double tmp;
if (x <= -2.4e+139) {
tmp = t_3;
} else if (x <= -1.8e-122) {
tmp = t_2;
} else if (x <= 1.25e-168) {
tmp = t_0;
} else if (x <= 1.55e-114) {
tmp = t_2;
} else if (x <= 5e-23) {
tmp = t_0;
} else {
tmp = t_3;
}
return tmp;
}
def code(x, y, z): t_0 = (math.log(y) * -0.5) - z t_1 = y * (1.0 - math.log(y)) t_2 = t_1 - z t_3 = x + t_1 tmp = 0 if x <= -2.4e+139: tmp = t_3 elif x <= -1.8e-122: tmp = t_2 elif x <= 1.25e-168: tmp = t_0 elif x <= 1.55e-114: tmp = t_2 elif x <= 5e-23: tmp = t_0 else: tmp = t_3 return tmp
function code(x, y, z) t_0 = Float64(Float64(log(y) * -0.5) - z) t_1 = Float64(y * Float64(1.0 - log(y))) t_2 = Float64(t_1 - z) t_3 = Float64(x + t_1) tmp = 0.0 if (x <= -2.4e+139) tmp = t_3; elseif (x <= -1.8e-122) tmp = t_2; elseif (x <= 1.25e-168) tmp = t_0; elseif (x <= 1.55e-114) tmp = t_2; elseif (x <= 5e-23) tmp = t_0; else tmp = t_3; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (log(y) * -0.5) - z; t_1 = y * (1.0 - log(y)); t_2 = t_1 - z; t_3 = x + t_1; tmp = 0.0; if (x <= -2.4e+139) tmp = t_3; elseif (x <= -1.8e-122) tmp = t_2; elseif (x <= 1.25e-168) tmp = t_0; elseif (x <= 1.55e-114) tmp = t_2; elseif (x <= 5e-23) tmp = t_0; else tmp = t_3; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - z), $MachinePrecision]}, Block[{t$95$3 = N[(x + t$95$1), $MachinePrecision]}, If[LessEqual[x, -2.4e+139], t$95$3, If[LessEqual[x, -1.8e-122], t$95$2, If[LessEqual[x, 1.25e-168], t$95$0, If[LessEqual[x, 1.55e-114], t$95$2, If[LessEqual[x, 5e-23], t$95$0, t$95$3]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log y \cdot -0.5 - z\\
t_1 := y \cdot \left(1 - \log y\right)\\
t_2 := t_1 - z\\
t_3 := x + t_1\\
\mathbf{if}\;x \leq -2.4 \cdot 10^{+139}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-122}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-168}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-114}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-23}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}
\end{array}
if x < -2.40000000000000008e139 or 5.0000000000000002e-23 < 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-def100.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 88.8%
if -2.40000000000000008e139 < x < -1.79999999999999997e-122 or 1.25e-168 < x < 1.55e-114Initial program 99.8%
*-commutative99.8%
distribute-lft-in99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 77.7%
sub-neg77.7%
log-rec77.7%
neg-mul-177.7%
remove-double-neg77.7%
sub-neg77.7%
Simplified77.7%
if -1.79999999999999997e-122 < x < 1.25e-168 or 1.55e-114 < x < 5.0000000000000002e-23Initial program 99.9%
*-commutative99.9%
distribute-lft-in99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 99.9%
+-commutative99.9%
metadata-eval99.9%
cancel-sign-sub-inv99.9%
distribute-rgt-out--99.9%
Simplified99.9%
Taylor expanded in y around 0 76.1%
*-commutative76.1%
Simplified76.1%
Final simplification81.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (- 1.0 (log y))))
(t_1 (- t_0 z))
(t_2 (- (- x (* (log y) 0.5)) z)))
(if (<= y 1.35e+37)
t_2
(if (<= y 4.8e+49)
t_1
(if (<= y 1.02e+103) t_2 (if (<= y 1.72e+159) t_1 (+ x t_0)))))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - log(y));
double t_1 = t_0 - z;
double t_2 = (x - (log(y) * 0.5)) - z;
double tmp;
if (y <= 1.35e+37) {
tmp = t_2;
} else if (y <= 4.8e+49) {
tmp = t_1;
} else if (y <= 1.02e+103) {
tmp = t_2;
} else if (y <= 1.72e+159) {
tmp = t_1;
} else {
tmp = x + t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = y * (1.0d0 - log(y))
t_1 = t_0 - z
t_2 = (x - (log(y) * 0.5d0)) - z
if (y <= 1.35d+37) then
tmp = t_2
else if (y <= 4.8d+49) then
tmp = t_1
else if (y <= 1.02d+103) then
tmp = t_2
else if (y <= 1.72d+159) then
tmp = t_1
else
tmp = x + t_0
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 = t_0 - z;
double t_2 = (x - (Math.log(y) * 0.5)) - z;
double tmp;
if (y <= 1.35e+37) {
tmp = t_2;
} else if (y <= 4.8e+49) {
tmp = t_1;
} else if (y <= 1.02e+103) {
tmp = t_2;
} else if (y <= 1.72e+159) {
tmp = t_1;
} else {
tmp = x + t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 - math.log(y)) t_1 = t_0 - z t_2 = (x - (math.log(y) * 0.5)) - z tmp = 0 if y <= 1.35e+37: tmp = t_2 elif y <= 4.8e+49: tmp = t_1 elif y <= 1.02e+103: tmp = t_2 elif y <= 1.72e+159: tmp = t_1 else: tmp = x + t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - log(y))) t_1 = Float64(t_0 - z) t_2 = Float64(Float64(x - Float64(log(y) * 0.5)) - z) tmp = 0.0 if (y <= 1.35e+37) tmp = t_2; elseif (y <= 4.8e+49) tmp = t_1; elseif (y <= 1.02e+103) tmp = t_2; elseif (y <= 1.72e+159) tmp = t_1; else tmp = Float64(x + t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 - log(y)); t_1 = t_0 - z; t_2 = (x - (log(y) * 0.5)) - z; tmp = 0.0; if (y <= 1.35e+37) tmp = t_2; elseif (y <= 4.8e+49) tmp = t_1; elseif (y <= 1.02e+103) tmp = t_2; elseif (y <= 1.72e+159) tmp = t_1; else tmp = x + t_0; 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[(t$95$0 - z), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[y, 1.35e+37], t$95$2, If[LessEqual[y, 4.8e+49], t$95$1, If[LessEqual[y, 1.02e+103], t$95$2, If[LessEqual[y, 1.72e+159], t$95$1, N[(x + t$95$0), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - \log y\right)\\
t_1 := t_0 - z\\
t_2 := \left(x - \log y \cdot 0.5\right) - z\\
\mathbf{if}\;y \leq 1.35 \cdot 10^{+37}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+49}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{+103}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq 1.72 \cdot 10^{+159}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;x + t_0\\
\end{array}
\end{array}
if y < 1.34999999999999993e37 or 4.8e49 < y < 1.01999999999999991e103Initial program 100.0%
Taylor expanded in y around 0 96.4%
if 1.34999999999999993e37 < y < 4.8e49 or 1.01999999999999991e103 < y < 1.72e159Initial program 99.7%
*-commutative99.7%
distribute-lft-in99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 83.1%
sub-neg83.1%
log-rec83.1%
neg-mul-183.1%
remove-double-neg83.1%
sub-neg83.1%
Simplified83.1%
if 1.72e159 < 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-def99.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 z around 0 89.6%
Final simplification93.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (- 1.0 (log y)))) (t_1 (- (- x (* (log y) 0.5)) z)))
(if (<= y 3.7e+37)
t_1
(if (<= y 3.5e+49)
(- t_0 z)
(if (<= y 1.05e+103)
t_1
(if (<= y 5.1e+158) (- (- y (* y (log y))) z) (+ x t_0)))))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - log(y));
double t_1 = (x - (log(y) * 0.5)) - z;
double tmp;
if (y <= 3.7e+37) {
tmp = t_1;
} else if (y <= 3.5e+49) {
tmp = t_0 - z;
} else if (y <= 1.05e+103) {
tmp = t_1;
} else if (y <= 5.1e+158) {
tmp = (y - (y * log(y))) - z;
} else {
tmp = x + t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y * (1.0d0 - log(y))
t_1 = (x - (log(y) * 0.5d0)) - z
if (y <= 3.7d+37) then
tmp = t_1
else if (y <= 3.5d+49) then
tmp = t_0 - z
else if (y <= 1.05d+103) then
tmp = t_1
else if (y <= 5.1d+158) then
tmp = (y - (y * log(y))) - z
else
tmp = x + t_0
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)) - z;
double tmp;
if (y <= 3.7e+37) {
tmp = t_1;
} else if (y <= 3.5e+49) {
tmp = t_0 - z;
} else if (y <= 1.05e+103) {
tmp = t_1;
} else if (y <= 5.1e+158) {
tmp = (y - (y * Math.log(y))) - z;
} else {
tmp = x + t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 - math.log(y)) t_1 = (x - (math.log(y) * 0.5)) - z tmp = 0 if y <= 3.7e+37: tmp = t_1 elif y <= 3.5e+49: tmp = t_0 - z elif y <= 1.05e+103: tmp = t_1 elif y <= 5.1e+158: tmp = (y - (y * math.log(y))) - z else: tmp = x + t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - log(y))) t_1 = Float64(Float64(x - Float64(log(y) * 0.5)) - z) tmp = 0.0 if (y <= 3.7e+37) tmp = t_1; elseif (y <= 3.5e+49) tmp = Float64(t_0 - z); elseif (y <= 1.05e+103) tmp = t_1; elseif (y <= 5.1e+158) tmp = Float64(Float64(y - Float64(y * log(y))) - z); else tmp = Float64(x + t_0); 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)) - z; tmp = 0.0; if (y <= 3.7e+37) tmp = t_1; elseif (y <= 3.5e+49) tmp = t_0 - z; elseif (y <= 1.05e+103) tmp = t_1; elseif (y <= 5.1e+158) tmp = (y - (y * log(y))) - z; else tmp = x + t_0; 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[(N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[y, 3.7e+37], t$95$1, If[LessEqual[y, 3.5e+49], N[(t$95$0 - z), $MachinePrecision], If[LessEqual[y, 1.05e+103], t$95$1, If[LessEqual[y, 5.1e+158], N[(N[(y - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(x + t$95$0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - \log y\right)\\
t_1 := \left(x - \log y \cdot 0.5\right) - z\\
\mathbf{if}\;y \leq 3.7 \cdot 10^{+37}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{+49}:\\
\;\;\;\;t_0 - z\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 5.1 \cdot 10^{+158}:\\
\;\;\;\;\left(y - y \cdot \log y\right) - z\\
\mathbf{else}:\\
\;\;\;\;x + t_0\\
\end{array}
\end{array}
if y < 3.6999999999999999e37 or 3.49999999999999975e49 < y < 1.0500000000000001e103Initial program 100.0%
Taylor expanded in y around 0 96.4%
if 3.6999999999999999e37 < y < 3.49999999999999975e49Initial program 99.7%
*-commutative99.7%
distribute-lft-in99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 99.7%
sub-neg99.7%
log-rec99.7%
neg-mul-199.7%
remove-double-neg99.7%
sub-neg99.7%
Simplified99.7%
if 1.0500000000000001e103 < y < 5.09999999999999987e158Initial program 99.8%
*-commutative99.8%
flip-+84.6%
associate-*r/84.4%
fma-neg84.4%
metadata-eval84.4%
metadata-eval84.4%
sub-neg84.4%
metadata-eval84.4%
Applied egg-rr84.4%
associate-/l*84.6%
+-commutative84.6%
Simplified84.6%
Taylor expanded in y around inf 99.7%
Taylor expanded in x around 0 79.2%
if 5.09999999999999987e158 < 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-def99.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 z around 0 89.6%
Final simplification93.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.42e-16) (not (<= x 2.8e-24))) (+ x (* y (- 1.0 (log y)))) (- (* (log y) -0.5) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.42e-16) || !(x <= 2.8e-24)) {
tmp = x + (y * (1.0 - log(y)));
} 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 <= (-1.42d-16)) .or. (.not. (x <= 2.8d-24))) then
tmp = x + (y * (1.0d0 - log(y)))
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 <= -1.42e-16) || !(x <= 2.8e-24)) {
tmp = x + (y * (1.0 - Math.log(y)));
} else {
tmp = (Math.log(y) * -0.5) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.42e-16) or not (x <= 2.8e-24): tmp = x + (y * (1.0 - math.log(y))) else: tmp = (math.log(y) * -0.5) - z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.42e-16) || !(x <= 2.8e-24)) tmp = Float64(x + Float64(y * Float64(1.0 - log(y)))); 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 <= -1.42e-16) || ~((x <= 2.8e-24))) tmp = x + (y * (1.0 - log(y))); else tmp = (log(y) * -0.5) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.42e-16], N[Not[LessEqual[x, 2.8e-24]], $MachinePrecision]], N[(x + N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.42 \cdot 10^{-16} \lor \neg \left(x \leq 2.8 \cdot 10^{-24}\right):\\
\;\;\;\;x + y \cdot \left(1 - \log y\right)\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\end{array}
\end{array}
if x < -1.4199999999999999e-16 or 2.8000000000000002e-24 < x Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
associate-+l+99.8%
associate-+r-99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-def100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
log-rec100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 84.0%
if -1.4199999999999999e-16 < x < 2.8000000000000002e-24Initial program 99.9%
*-commutative99.9%
distribute-lft-in99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 99.9%
+-commutative99.9%
metadata-eval99.9%
cancel-sign-sub-inv99.9%
distribute-rgt-out--99.9%
Simplified99.9%
Taylor expanded in y around 0 70.5%
*-commutative70.5%
Simplified70.5%
Final simplification77.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -0.021) (not (<= x 11500000.0))) (- x z) (- (* (log y) -0.5) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -0.021) || !(x <= 11500000.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 <= (-0.021d0)) .or. (.not. (x <= 11500000.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 <= -0.021) || !(x <= 11500000.0)) {
tmp = x - z;
} else {
tmp = (Math.log(y) * -0.5) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -0.021) or not (x <= 11500000.0): tmp = x - z else: tmp = (math.log(y) * -0.5) - z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -0.021) || !(x <= 11500000.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 <= -0.021) || ~((x <= 11500000.0))) tmp = x - z; else tmp = (log(y) * -0.5) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -0.021], N[Not[LessEqual[x, 11500000.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 -0.021 \lor \neg \left(x \leq 11500000\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\end{array}
\end{array}
if x < -0.0210000000000000013 or 1.15e7 < x Initial program 99.9%
*-commutative99.9%
distribute-lft-in99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 75.3%
if -0.0210000000000000013 < x < 1.15e7Initial program 99.8%
*-commutative99.8%
distribute-lft-in99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 99.9%
+-commutative99.9%
metadata-eval99.9%
cancel-sign-sub-inv99.9%
distribute-rgt-out--99.8%
Simplified99.8%
Taylor expanded in y around 0 67.9%
*-commutative67.9%
Simplified67.9%
Final simplification71.3%
(FPCore (x y z) :precision binary64 (if (<= y 1.6e-5) (- (- 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 <= 1.6e-5) {
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 <= 1.6d-5) 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 <= 1.6e-5) {
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 <= 1.6e-5: 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 <= 1.6e-5) 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 <= 1.6e-5) 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, 1.6e-5], 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 1.6 \cdot 10^{-5}:\\
\;\;\;\;\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 < 1.59999999999999993e-5Initial program 100.0%
Taylor expanded in y around 0 99.0%
if 1.59999999999999993e-5 < y Initial program 99.8%
associate--l+99.7%
sub-neg99.7%
associate-+l+99.7%
associate-+r-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 y around inf 99.8%
log-rec99.8%
sub-neg99.8%
Simplified99.8%
Final simplification99.4%
(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.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= x -3.55e+130) x (if (<= x 7700000000.0) (- z) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.55e+130) {
tmp = x;
} else if (x <= 7700000000.0) {
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 <= (-3.55d+130)) then
tmp = x
else if (x <= 7700000000.0d0) 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 <= -3.55e+130) {
tmp = x;
} else if (x <= 7700000000.0) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.55e+130: tmp = x elif x <= 7700000000.0: tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3.55e+130) tmp = x; elseif (x <= 7700000000.0) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3.55e+130) tmp = x; elseif (x <= 7700000000.0) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.55e+130], x, If[LessEqual[x, 7700000000.0], (-z), x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.55 \cdot 10^{+130}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 7700000000:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -3.5500000000000001e130 or 7.7e9 < 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-def100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 66.9%
if -3.5500000000000001e130 < x < 7.7e9Initial 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-def99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 68.6%
log-rec68.6%
sub-neg68.6%
Simplified68.6%
Taylor expanded in z around inf 33.5%
neg-mul-133.5%
Simplified33.5%
Final simplification46.8%
(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.9%
*-commutative99.9%
distribute-lft-in99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 52.6%
Final simplification52.6%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
associate-+l+99.9%
associate-+r-99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-def99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 30.0%
Final simplification30.0%
(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 2024021
(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))