| Alternative 1 | |
|---|---|
| Accuracy | 98.4% |
| 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 (if (<= y 2e-58) (+ 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 tmp;
if (y <= 2e-58) {
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) :: tmp
if (y <= 2d-58) 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 tmp;
if (y <= 2e-58) {
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): tmp = 0 if y <= 2e-58: 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) tmp = 0.0 if (y <= 2e-58) 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) tmp = 0.0; if (y <= 2e-58) 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_] := If[LessEqual[y, 2e-58], 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}
\mathbf{if}\;y \leq 2 \cdot 10^{-58}:\\
\;\;\;\;x + \frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{e^{-z}}{y}\\
\end{array}
Results
| Original | 90.9% |
|---|---|
| Target | 98.5% |
| Herbie | 98.1% |
if y < 2.0000000000000001e-58Initial program 87.6%
Simplified98.9%
[Start]87.6 | \[ x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}
\] |
|---|---|
exp-prod [=>]98.9 | \[ x + \frac{\color{blue}{{\left(e^{y}\right)}^{\log \left(\frac{y}{z + y}\right)}}}{y}
\] |
sqr-pow [=>]98.9 | \[ x + \frac{\color{blue}{{\left(e^{y}\right)}^{\left(\frac{\log \left(\frac{y}{z + y}\right)}{2}\right)} \cdot {\left(e^{y}\right)}^{\left(\frac{\log \left(\frac{y}{z + y}\right)}{2}\right)}}}{y}
\] |
sqr-pow [<=]98.9 | \[ x + \frac{\color{blue}{{\left(e^{y}\right)}^{\log \left(\frac{y}{z + y}\right)}}}{y}
\] |
+-commutative [=>]98.9 | \[ x + \frac{{\left(e^{y}\right)}^{\log \left(\frac{y}{\color{blue}{y + z}}\right)}}{y}
\] |
Taylor expanded in y around 0 98.5%
if 2.0000000000000001e-58 < y Initial program 97.4%
Simplified97.4%
[Start]97.4 | \[ x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}
\] |
|---|---|
*-commutative [=>]97.4 | \[ x + \frac{e^{\color{blue}{\log \left(\frac{y}{z + y}\right) \cdot y}}}{y}
\] |
exp-prod [=>]97.4 | \[ x + \frac{\color{blue}{{\left(e^{\log \left(\frac{y}{z + y}\right)}\right)}^{y}}}{y}
\] |
rem-exp-log [=>]97.4 | \[ x + \frac{{\color{blue}{\left(\frac{y}{z + y}\right)}}^{y}}{y}
\] |
+-commutative [=>]97.4 | \[ x + \frac{{\left(\frac{y}{\color{blue}{y + z}}\right)}^{y}}{y}
\] |
Taylor expanded in y around inf 97.5%
Simplified97.5%
[Start]97.5 | \[ x + \frac{e^{-1 \cdot z}}{y}
\] |
|---|---|
mul-1-neg [=>]97.5 | \[ x + \frac{e^{\color{blue}{-z}}}{y}
\] |
Final simplification98.1%
| Alternative 1 | |
|---|---|
| Accuracy | 98.4% |
| Cost | 19840 |
| Alternative 2 | |
|---|---|
| Accuracy | 96.6% |
| Cost | 320 |
herbie shell --seed 2023141
(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)))