
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + y) - z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - ((y + 0.5) * log(y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + y) - z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - ((y + 0.5) * log(y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}
(FPCore (x y z) :precision binary64 (+ x (- (fma (log y) (- -0.5 y) y) z)))
double code(double x, double y, double z) {
return x + (fma(log(y), (-0.5 - y), y) - z);
}
function code(x, y, z) return Float64(x + 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
(if (<= y 4.3e-184)
(- x z)
(if (<= y 2.75e-127)
(+ x (* (log y) -0.5))
(if (<= y 8.1e+102) (- x z) (* y (- 1.0 (log y)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.3e-184) {
tmp = x - z;
} else if (y <= 2.75e-127) {
tmp = x + (log(y) * -0.5);
} else if (y <= 8.1e+102) {
tmp = x - z;
} else {
tmp = y * (1.0 - log(y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 4.3d-184) then
tmp = x - z
else if (y <= 2.75d-127) then
tmp = x + (log(y) * (-0.5d0))
else if (y <= 8.1d+102) then
tmp = x - z
else
tmp = y * (1.0d0 - log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 4.3e-184) {
tmp = x - z;
} else if (y <= 2.75e-127) {
tmp = x + (Math.log(y) * -0.5);
} else if (y <= 8.1e+102) {
tmp = x - z;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4.3e-184: tmp = x - z elif y <= 2.75e-127: tmp = x + (math.log(y) * -0.5) elif y <= 8.1e+102: tmp = x - z else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4.3e-184) tmp = Float64(x - z); elseif (y <= 2.75e-127) tmp = Float64(x + Float64(log(y) * -0.5)); elseif (y <= 8.1e+102) tmp = Float64(x - z); else tmp = Float64(y * Float64(1.0 - log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4.3e-184) tmp = x - z; elseif (y <= 2.75e-127) tmp = x + (log(y) * -0.5); elseif (y <= 8.1e+102) tmp = x - z; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4.3e-184], N[(x - z), $MachinePrecision], If[LessEqual[y, 2.75e-127], N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.1e+102], N[(x - z), $MachinePrecision], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.3 \cdot 10^{-184}:\\
\;\;\;\;x - z\\
\mathbf{elif}\;y \leq 2.75 \cdot 10^{-127}:\\
\;\;\;\;x + \log y \cdot -0.5\\
\mathbf{elif}\;y \leq 8.1 \cdot 10^{+102}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 4.30000000000000007e-184 or 2.75000000000000018e-127 < y < 8.10000000000000037e102Initial program 99.9%
associate--l+99.9%
Simplified99.9%
add-sqr-sqrt99.6%
pow299.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 96.2%
mul-1-neg96.2%
associate-/l*96.2%
+-commutative96.2%
unsub-neg96.2%
associate-*r/96.2%
*-commutative96.2%
associate-*r/96.2%
*-commutative96.2%
+-commutative96.2%
Simplified96.2%
Taylor expanded in y around inf 81.2%
Taylor expanded in y around 0 74.9%
if 4.30000000000000007e-184 < y < 2.75000000000000018e-127Initial 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 100.0%
Taylor expanded in z around 0 77.8%
if 8.10000000000000037e102 < 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 74.4%
log-rec74.4%
sub-neg74.4%
Simplified74.4%
Final simplification75.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -400000000.0) (not (<= z 2.4e+24))) (- (- y z) (* y (log y))) (- (+ x y) (* (log y) (+ y 0.5)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -400000000.0) || !(z <= 2.4e+24)) {
tmp = (y - z) - (y * log(y));
} else {
tmp = (x + y) - (log(y) * (y + 0.5));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-400000000.0d0)) .or. (.not. (z <= 2.4d+24))) then
tmp = (y - z) - (y * log(y))
else
tmp = (x + y) - (log(y) * (y + 0.5d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -400000000.0) || !(z <= 2.4e+24)) {
tmp = (y - z) - (y * Math.log(y));
} else {
tmp = (x + y) - (Math.log(y) * (y + 0.5));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -400000000.0) or not (z <= 2.4e+24): tmp = (y - z) - (y * math.log(y)) else: tmp = (x + y) - (math.log(y) * (y + 0.5)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -400000000.0) || !(z <= 2.4e+24)) tmp = Float64(Float64(y - z) - Float64(y * log(y))); else tmp = Float64(Float64(x + y) - Float64(log(y) * Float64(y + 0.5))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -400000000.0) || ~((z <= 2.4e+24))) tmp = (y - z) - (y * log(y)); else tmp = (x + y) - (log(y) * (y + 0.5)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -400000000.0], N[Not[LessEqual[z, 2.4e+24]], $MachinePrecision]], N[(N[(y - z), $MachinePrecision] - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + y), $MachinePrecision] - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -400000000 \lor \neg \left(z \leq 2.4 \cdot 10^{+24}\right):\\
\;\;\;\;\left(y - z\right) - y \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) - \log y \cdot \left(y + 0.5\right)\\
\end{array}
\end{array}
if z < -4e8 or 2.4000000000000001e24 < z Initial program 99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 88.2%
log-rec88.2%
Simplified88.2%
Taylor expanded in z around 0 88.2%
neg-mul-188.2%
associate-+r+88.2%
sub-neg88.2%
mul-1-neg88.2%
unsub-neg88.2%
Simplified88.2%
if -4e8 < z < 2.4000000000000001e24Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in z around 0 98.3%
Final simplification93.8%
(FPCore (x y z) :precision binary64 (if (<= y 52.0) (- (+ x (* (log y) -0.5)) z) (* y (+ (- 1.0 (log y)) (/ (- x z) y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 52.0) {
tmp = (x + (log(y) * -0.5)) - z;
} else {
tmp = y * ((1.0 - log(y)) + ((x - z) / 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 <= 52.0d0) then
tmp = (x + (log(y) * (-0.5d0))) - z
else
tmp = y * ((1.0d0 - log(y)) + ((x - z) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 52.0) {
tmp = (x + (Math.log(y) * -0.5)) - z;
} else {
tmp = y * ((1.0 - Math.log(y)) + ((x - z) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 52.0: tmp = (x + (math.log(y) * -0.5)) - z else: tmp = y * ((1.0 - math.log(y)) + ((x - z) / y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 52.0) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z); else tmp = Float64(y * Float64(Float64(1.0 - log(y)) + Float64(Float64(x - z) / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 52.0) tmp = (x + (log(y) * -0.5)) - z; else tmp = y * ((1.0 - log(y)) + ((x - z) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 52.0], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(y * N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 52:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(\left(1 - \log y\right) + \frac{x - z}{y}\right)\\
\end{array}
\end{array}
if y < 52Initial 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.5%
if 52 < y Initial program 99.7%
associate--l+99.7%
Simplified99.7%
add-sqr-sqrt99.4%
pow299.4%
Applied egg-rr99.4%
Taylor expanded in x around inf 78.8%
mul-1-neg78.8%
associate-/l*78.8%
+-commutative78.8%
unsub-neg78.8%
associate-*r/78.8%
*-commutative78.8%
associate-*r/78.7%
*-commutative78.7%
+-commutative78.7%
Simplified78.7%
Taylor expanded in y around inf 78.3%
Taylor expanded in y around inf 99.2%
log-rec99.2%
associate-+r+99.2%
sub-neg99.2%
associate--l+99.2%
div-sub99.2%
Simplified99.2%
Final simplification99.3%
(FPCore (x y z) :precision binary64 (if (<= y 2.8e-128) (- (* (log y) -0.5) z) (if (<= y 1.42e+103) (- x z) (* y (- 1.0 (log y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.8e-128) {
tmp = (log(y) * -0.5) - z;
} else if (y <= 1.42e+103) {
tmp = x - z;
} else {
tmp = y * (1.0 - log(y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 2.8d-128) then
tmp = (log(y) * (-0.5d0)) - z
else if (y <= 1.42d+103) then
tmp = x - z
else
tmp = y * (1.0d0 - log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.8e-128) {
tmp = (Math.log(y) * -0.5) - z;
} else if (y <= 1.42e+103) {
tmp = x - z;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.8e-128: tmp = (math.log(y) * -0.5) - z elif y <= 1.42e+103: tmp = x - z else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.8e-128) tmp = Float64(Float64(log(y) * -0.5) - z); elseif (y <= 1.42e+103) tmp = Float64(x - z); else tmp = Float64(y * Float64(1.0 - log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.8e-128) tmp = (log(y) * -0.5) - z; elseif (y <= 1.42e+103) tmp = x - z; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.8e-128], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[y, 1.42e+103], N[(x - z), $MachinePrecision], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.8 \cdot 10^{-128}:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\mathbf{elif}\;y \leq 1.42 \cdot 10^{+103}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 2.7999999999999998e-128Initial 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 100.0%
Taylor expanded in x around 0 77.6%
*-commutative77.6%
Simplified77.6%
if 2.7999999999999998e-128 < y < 1.42e103Initial program 99.9%
associate--l+99.9%
Simplified99.9%
add-sqr-sqrt99.6%
pow299.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 94.4%
mul-1-neg94.4%
associate-/l*94.4%
+-commutative94.4%
unsub-neg94.4%
associate-*r/94.4%
*-commutative94.4%
associate-*r/94.4%
*-commutative94.4%
+-commutative94.4%
Simplified94.4%
Taylor expanded in y around inf 81.1%
Taylor expanded in y around 0 71.8%
if 1.42e103 < 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 74.4%
log-rec74.4%
sub-neg74.4%
Simplified74.4%
(FPCore (x y z) :precision binary64 (if (<= y 6e+19) (- (+ x (* (log y) -0.5)) z) (- (- y z) (* y (log y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 6e+19) {
tmp = (x + (log(y) * -0.5)) - z;
} else {
tmp = (y - z) - (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 <= 6d+19) then
tmp = (x + (log(y) * (-0.5d0))) - z
else
tmp = (y - z) - (y * log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 6e+19) {
tmp = (x + (Math.log(y) * -0.5)) - z;
} else {
tmp = (y - z) - (y * Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 6e+19: tmp = (x + (math.log(y) * -0.5)) - z else: tmp = (y - z) - (y * math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 6e+19) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z); else tmp = Float64(Float64(y - z) - Float64(y * log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 6e+19) tmp = (x + (log(y) * -0.5)) - z; else tmp = (y - z) - (y * log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 6e+19], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(y - z), $MachinePrecision] - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6 \cdot 10^{+19}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(y - z\right) - y \cdot \log y\\
\end{array}
\end{array}
if y < 6e19Initial 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 98.9%
if 6e19 < y Initial program 99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in y around inf 81.2%
log-rec81.2%
Simplified81.2%
Taylor expanded in z around 0 81.2%
neg-mul-181.2%
associate-+r+81.2%
sub-neg81.2%
mul-1-neg81.2%
unsub-neg81.2%
Simplified81.2%
Final simplification90.9%
(FPCore (x y z) :precision binary64 (if (<= y 7.3e+102) (- (+ x (* (log y) -0.5)) z) (* y (- 1.0 (log y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 7.3e+102) {
tmp = (x + (log(y) * -0.5)) - 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 <= 7.3d+102) then
tmp = (x + (log(y) * (-0.5d0))) - 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 <= 7.3e+102) {
tmp = (x + (Math.log(y) * -0.5)) - z;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 7.3e+102: tmp = (x + (math.log(y) * -0.5)) - z else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 7.3e+102) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - 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 <= 7.3e+102) tmp = (x + (log(y) * -0.5)) - z; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 7.3e+102], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.3 \cdot 10^{+102}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 7.29999999999999989e102Initial 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 91.0%
if 7.29999999999999989e102 < 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 74.4%
log-rec74.4%
sub-neg74.4%
Simplified74.4%
Final simplification85.9%
(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 (<= y 5.3e+102) (- x z) (* y (- 1.0 (log y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 5.3e+102) {
tmp = x - z;
} else {
tmp = y * (1.0 - log(y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 5.3d+102) then
tmp = x - z
else
tmp = y * (1.0d0 - log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 5.3e+102) {
tmp = x - z;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5.3e+102: tmp = x - z else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5.3e+102) tmp = Float64(x - z); else tmp = Float64(y * Float64(1.0 - log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 5.3e+102) tmp = x - z; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5.3e+102], N[(x - z), $MachinePrecision], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.3 \cdot 10^{+102}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 5.2999999999999997e102Initial program 99.9%
associate--l+99.9%
Simplified99.9%
add-sqr-sqrt99.5%
pow299.5%
Applied egg-rr99.5%
Taylor expanded in x around inf 96.7%
mul-1-neg96.7%
associate-/l*96.7%
+-commutative96.7%
unsub-neg96.7%
associate-*r/96.7%
*-commutative96.7%
associate-*r/96.7%
*-commutative96.7%
+-commutative96.7%
Simplified96.7%
Taylor expanded in y around inf 75.7%
Taylor expanded in y around 0 70.2%
if 5.2999999999999997e102 < 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 74.4%
log-rec74.4%
sub-neg74.4%
Simplified74.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -2700000.0) (not (<= z 2.45e+20))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2700000.0) || !(z <= 2.45e+20)) {
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 <= (-2700000.0d0)) .or. (.not. (z <= 2.45d+20))) 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 <= -2700000.0) || !(z <= 2.45e+20)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2700000.0) or not (z <= 2.45e+20): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2700000.0) || !(z <= 2.45e+20)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2700000.0) || ~((z <= 2.45e+20))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2700000.0], N[Not[LessEqual[z, 2.45e+20]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2700000 \lor \neg \left(z \leq 2.45 \cdot 10^{+20}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -2.7e6 or 2.45e20 < 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-define99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 69.1%
neg-mul-169.1%
Simplified69.1%
if -2.7e6 < z < 2.45e20Initial 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 37.1%
Final simplification51.2%
(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%
Simplified99.8%
add-sqr-sqrt99.4%
pow299.4%
Applied egg-rr99.4%
Taylor expanded in x around inf 89.6%
mul-1-neg89.6%
associate-/l*89.6%
+-commutative89.6%
unsub-neg89.6%
associate-*r/89.6%
*-commutative89.6%
associate-*r/89.6%
*-commutative89.6%
+-commutative89.6%
Simplified89.6%
Taylor expanded in y around inf 75.0%
Taylor expanded in y around 0 56.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.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 26.4%
(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 2024151
(FPCore (x y z)
:name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (- (- (+ y x) z) (* (+ y 1/2) (log y))))
(- (+ (- x (* (+ y 0.5) (log y))) y) z))