(FPCore (x y z) :precision binary64 (+ x (/ (exp (* y (log (/ y (+ z y))))) y)))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (+ y z))) (t_1 (+ x (/ (exp (* y (log t_0))) y))))
(if (<= t_1 -3.773824059460863e-188)
(+ x (/ 1.0 y))
(if (<= t_1 2.9769590526251184e-166)
(+ x (/ (exp (- z)) y))
(+ x (/ (pow t_0 y) y))))))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 = y / (y + z);
double t_1 = x + (exp((y * log(t_0))) / y);
double tmp;
if (t_1 <= -3.773824059460863e-188) {
tmp = x + (1.0 / y);
} else if (t_1 <= 2.9769590526251184e-166) {
tmp = x + (exp(-z) / y);
} else {
tmp = x + (pow(t_0, y) / 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
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 = y / (y + z)
t_1 = x + (exp((y * log(t_0))) / y)
if (t_1 <= (-3.773824059460863d-188)) then
tmp = x + (1.0d0 / y)
else if (t_1 <= 2.9769590526251184d-166) then
tmp = x + (exp(-z) / y)
else
tmp = x + ((t_0 ** y) / y)
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 = y / (y + z);
double t_1 = x + (Math.exp((y * Math.log(t_0))) / y);
double tmp;
if (t_1 <= -3.773824059460863e-188) {
tmp = x + (1.0 / y);
} else if (t_1 <= 2.9769590526251184e-166) {
tmp = x + (Math.exp(-z) / y);
} else {
tmp = x + (Math.pow(t_0, y) / y);
}
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 = y / (y + z) t_1 = x + (math.exp((y * math.log(t_0))) / y) tmp = 0 if t_1 <= -3.773824059460863e-188: tmp = x + (1.0 / y) elif t_1 <= 2.9769590526251184e-166: tmp = x + (math.exp(-z) / y) else: tmp = x + (math.pow(t_0, y) / y) 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(y / Float64(y + z)) t_1 = Float64(x + Float64(exp(Float64(y * log(t_0))) / y)) tmp = 0.0 if (t_1 <= -3.773824059460863e-188) tmp = Float64(x + Float64(1.0 / y)); elseif (t_1 <= 2.9769590526251184e-166) tmp = Float64(x + Float64(exp(Float64(-z)) / y)); else tmp = Float64(x + Float64((t_0 ^ y) / y)); 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 = y / (y + z); t_1 = x + (exp((y * log(t_0))) / y); tmp = 0.0; if (t_1 <= -3.773824059460863e-188) tmp = x + (1.0 / y); elseif (t_1 <= 2.9769590526251184e-166) tmp = x + (exp(-z) / y); else tmp = x + ((t_0 ^ y) / y); 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[(y / N[(y + z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(N[Exp[N[(y * N[Log[t$95$0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -3.773824059460863e-188], N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2.9769590526251184e-166], N[(x + N[(N[Exp[(-z)], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Power[t$95$0, y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]
x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}
\begin{array}{l}
t_0 := \frac{y}{y + z}\\
t_1 := x + \frac{e^{y \cdot \log t_0}}{y}\\
\mathbf{if}\;t_1 \leq -3.773824059460863 \cdot 10^{-188}:\\
\;\;\;\;x + \frac{1}{y}\\
\mathbf{elif}\;t_1 \leq 2.9769590526251184 \cdot 10^{-166}:\\
\;\;\;\;x + \frac{e^{-z}}{y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{{t_0}^{y}}{y}\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 5.8 |
|---|---|
| Target | 1.0 |
| Herbie | 2.3 |
if (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < -3.7738240594608627e-188Initial program 7.4
Simplified7.4
Taylor expanded in y around 0 1.3
if -3.7738240594608627e-188 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < 2.9769590526251184e-166Initial program 15.9
Simplified15.9
Taylor expanded in y around inf 9.6
if 2.9769590526251184e-166 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) Initial program 2.3
Simplified2.3
Applied egg-rr2.3
Applied egg-rr2.3
Final simplification2.3
herbie shell --seed 2022150
(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)))