(FPCore (x y z) :precision binary64 (+ x (/ (exp (* y (log (/ y (+ z y))))) y)))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (/ 1.0 y)))
(t_1 (+ x (/ (exp (* y (log (/ y (+ y z))))) y))))
(if (<= t_1 -2e-179) t_0 (if (<= t_1 4e-265) x t_0))))double code(double x, double y, double z) {
return x + (exp((y * log((y / (z + y))))) / y);
}
double code(double x, double y, double z) {
double t_0 = x + (1.0 / y);
double t_1 = x + (exp((y * log((y / (y + z))))) / y);
double tmp;
if (t_1 <= -2e-179) {
tmp = t_0;
} else if (t_1 <= 4e-265) {
tmp = x;
} else {
tmp = 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
code = x + (exp((y * log((y / (z + y))))) / y)
end function
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 + (1.0d0 / y)
t_1 = x + (exp((y * log((y / (y + z))))) / y)
if (t_1 <= (-2d-179)) then
tmp = t_0
else if (t_1 <= 4d-265) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return x + (Math.exp((y * Math.log((y / (z + y))))) / y);
}
public static double code(double x, double y, double z) {
double t_0 = x + (1.0 / y);
double t_1 = x + (Math.exp((y * Math.log((y / (y + z))))) / y);
double tmp;
if (t_1 <= -2e-179) {
tmp = t_0;
} else if (t_1 <= 4e-265) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): return x + (math.exp((y * math.log((y / (z + y))))) / y)
def code(x, y, z): t_0 = x + (1.0 / y) t_1 = x + (math.exp((y * math.log((y / (y + z))))) / y) tmp = 0 if t_1 <= -2e-179: tmp = t_0 elif t_1 <= 4e-265: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) return Float64(x + Float64(exp(Float64(y * log(Float64(y / Float64(z + y))))) / y)) end
function code(x, y, z) t_0 = Float64(x + Float64(1.0 / y)) t_1 = Float64(x + Float64(exp(Float64(y * log(Float64(y / Float64(y + z))))) / y)) tmp = 0.0 if (t_1 <= -2e-179) tmp = t_0; elseif (t_1 <= 4e-265) tmp = x; else tmp = t_0; end return tmp end
function tmp = code(x, y, z) tmp = x + (exp((y * log((y / (z + y))))) / y); end
function tmp_2 = code(x, y, z) t_0 = x + (1.0 / y); t_1 = x + (exp((y * log((y / (y + z))))) / y); tmp = 0.0; if (t_1 <= -2e-179) tmp = t_0; elseif (t_1 <= 4e-265) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := N[(x + N[(N[Exp[N[(y * N[Log[N[(y / N[(z + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(N[Exp[N[(y * N[Log[N[(y / N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-179], t$95$0, If[LessEqual[t$95$1, 4e-265], x, t$95$0]]]]
x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}
\begin{array}{l}
t_0 := x + \frac{1}{y}\\
t_1 := x + \frac{e^{y \cdot \log \left(\frac{y}{y + z}\right)}}{y}\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{-179}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_1 \leq 4 \cdot 10^{-265}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 6.1 |
|---|---|
| Target | 1.1 |
| Herbie | 3.1 |
if (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < -2e-179 or 3.99999999999999994e-265 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) Initial program 5.7
Simplified5.7
Taylor expanded in y around 0 1.9
if -2e-179 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < 3.99999999999999994e-265Initial program 14.4
Simplified14.4
Taylor expanded in x around inf 28.2
Final simplification3.1
herbie shell --seed 2022166
(FPCore (x y z)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, G"
:precision binary64
:herbie-target
(if (< (/ y (+ z y)) 7.11541576e-315) (+ x (/ (exp (/ -1.0 z)) y)) (+ x (/ (exp (log (pow (/ y (+ y z)) y))) y)))
(+ x (/ (exp (* y (log (/ y (+ z y))))) y)))