| Alternative 1 | |
|---|---|
| Error | 1.1 |
| Cost | 19840 |
\[x + \frac{{\left(e^{y}\right)}^{\log \left(\frac{y}{y + z}\right)}}{y}
\]
(FPCore (x y z) :precision binary64 (+ x (/ (exp (* y (log (/ y (+ z y))))) y)))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (/ (exp (* y (log (/ y (+ y z))))) y))))
(if (or (<= t_0 -5e-100) (not (<= t_0 2e-49)))
(+ x (/ 1.0 y))
(+ x (/ (exp (- z)) 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 = x + (exp((y * log((y / (y + z))))) / y);
double tmp;
if ((t_0 <= -5e-100) || !(t_0 <= 2e-49)) {
tmp = x + (1.0 / y);
} else {
tmp = x + (exp(-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
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) :: tmp
t_0 = x + (exp((y * log((y / (y + z))))) / y)
if ((t_0 <= (-5d-100)) .or. (.not. (t_0 <= 2d-49))) then
tmp = x + (1.0d0 / y)
else
tmp = x + (exp(-z) / 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 = x + (Math.exp((y * Math.log((y / (y + z))))) / y);
double tmp;
if ((t_0 <= -5e-100) || !(t_0 <= 2e-49)) {
tmp = x + (1.0 / y);
} else {
tmp = x + (Math.exp(-z) / 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 = x + (math.exp((y * math.log((y / (y + z))))) / y) tmp = 0 if (t_0 <= -5e-100) or not (t_0 <= 2e-49): tmp = x + (1.0 / y) else: tmp = x + (math.exp(-z) / 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(x + Float64(exp(Float64(y * log(Float64(y / Float64(y + z))))) / y)) tmp = 0.0 if ((t_0 <= -5e-100) || !(t_0 <= 2e-49)) tmp = Float64(x + Float64(1.0 / y)); else tmp = Float64(x + Float64(exp(Float64(-z)) / 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 = x + (exp((y * log((y / (y + z))))) / y); tmp = 0.0; if ((t_0 <= -5e-100) || ~((t_0 <= 2e-49))) tmp = x + (1.0 / y); else tmp = x + (exp(-z) / 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[(x + N[(N[Exp[N[(y * N[Log[N[(y / N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5e-100], N[Not[LessEqual[t$95$0, 2e-49]], $MachinePrecision]], N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Exp[(-z)], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}
\begin{array}{l}
t_0 := x + \frac{e^{y \cdot \log \left(\frac{y}{y + z}\right)}}{y}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{-100} \lor \neg \left(t_0 \leq 2 \cdot 10^{-49}\right):\\
\;\;\;\;x + \frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{e^{-z}}{y}\\
\end{array}
Results
| Original | 6.1 |
|---|---|
| Target | 1.1 |
| Herbie | 1.4 |
if (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < -5.0000000000000001e-100 or 1.99999999999999987e-49 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) Initial program 5.1
Simplified0.2
Taylor expanded in y around inf 0.5
if -5.0000000000000001e-100 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < 1.99999999999999987e-49Initial program 10.8
Simplified10.8
Taylor expanded in y around inf 5.7
Simplified5.7
Final simplification1.4
| Alternative 1 | |
|---|---|
| Error | 1.1 |
| Cost | 19840 |
| Alternative 2 | |
|---|---|
| Error | 15.3 |
| Cost | 720 |
| Alternative 3 | |
|---|---|
| Error | 2.3 |
| Cost | 320 |
| Alternative 4 | |
|---|---|
| Error | 28.2 |
| Cost | 64 |
herbie shell --seed 2022343
(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)))