| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 7620 |
\[\begin{array}{l}
t_0 := \frac{x - y}{1 - y}\\
\mathbf{if}\;t_0 \leq 0.99996:\\
\;\;\;\;1 - \log \left(1 - t_0\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(-\frac{1 - x}{y}\right)\\
\end{array}
\]
(FPCore (x y) :precision binary64 (- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (- x y) (- 1.0 y))))
(if (<= t_0 0.95)
(- 1.0 (log (- 1.0 t_0)))
(-
1.0
(log
(+
(+
(/ x (pow y 2.0))
(* -1.0 (+ (/ (- 1.0 x) y) (/ (+ 1.0 (* -1.0 x)) (pow y 3.0)))))
(- (/ x (pow y 4.0)) (+ (/ 1.0 (pow y 2.0)) (/ 1.0 (pow y 4.0))))))))))double code(double x, double y) {
return 1.0 - log((1.0 - ((x - y) / (1.0 - y))));
}
double code(double x, double y) {
double t_0 = (x - y) / (1.0 - y);
double tmp;
if (t_0 <= 0.95) {
tmp = 1.0 - log((1.0 - t_0));
} else {
tmp = 1.0 - log((((x / pow(y, 2.0)) + (-1.0 * (((1.0 - x) / y) + ((1.0 + (-1.0 * x)) / pow(y, 3.0))))) + ((x / pow(y, 4.0)) - ((1.0 / pow(y, 2.0)) + (1.0 / pow(y, 4.0))))));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - log((1.0d0 - ((x - y) / (1.0d0 - y))))
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x - y) / (1.0d0 - y)
if (t_0 <= 0.95d0) then
tmp = 1.0d0 - log((1.0d0 - t_0))
else
tmp = 1.0d0 - log((((x / (y ** 2.0d0)) + ((-1.0d0) * (((1.0d0 - x) / y) + ((1.0d0 + ((-1.0d0) * x)) / (y ** 3.0d0))))) + ((x / (y ** 4.0d0)) - ((1.0d0 / (y ** 2.0d0)) + (1.0d0 / (y ** 4.0d0))))))
end if
code = tmp
end function
public static double code(double x, double y) {
return 1.0 - Math.log((1.0 - ((x - y) / (1.0 - y))));
}
public static double code(double x, double y) {
double t_0 = (x - y) / (1.0 - y);
double tmp;
if (t_0 <= 0.95) {
tmp = 1.0 - Math.log((1.0 - t_0));
} else {
tmp = 1.0 - Math.log((((x / Math.pow(y, 2.0)) + (-1.0 * (((1.0 - x) / y) + ((1.0 + (-1.0 * x)) / Math.pow(y, 3.0))))) + ((x / Math.pow(y, 4.0)) - ((1.0 / Math.pow(y, 2.0)) + (1.0 / Math.pow(y, 4.0))))));
}
return tmp;
}
def code(x, y): return 1.0 - math.log((1.0 - ((x - y) / (1.0 - y))))
def code(x, y): t_0 = (x - y) / (1.0 - y) tmp = 0 if t_0 <= 0.95: tmp = 1.0 - math.log((1.0 - t_0)) else: tmp = 1.0 - math.log((((x / math.pow(y, 2.0)) + (-1.0 * (((1.0 - x) / y) + ((1.0 + (-1.0 * x)) / math.pow(y, 3.0))))) + ((x / math.pow(y, 4.0)) - ((1.0 / math.pow(y, 2.0)) + (1.0 / math.pow(y, 4.0)))))) return tmp
function code(x, y) return Float64(1.0 - log(Float64(1.0 - Float64(Float64(x - y) / Float64(1.0 - y))))) end
function code(x, y) t_0 = Float64(Float64(x - y) / Float64(1.0 - y)) tmp = 0.0 if (t_0 <= 0.95) tmp = Float64(1.0 - log(Float64(1.0 - t_0))); else tmp = Float64(1.0 - log(Float64(Float64(Float64(x / (y ^ 2.0)) + Float64(-1.0 * Float64(Float64(Float64(1.0 - x) / y) + Float64(Float64(1.0 + Float64(-1.0 * x)) / (y ^ 3.0))))) + Float64(Float64(x / (y ^ 4.0)) - Float64(Float64(1.0 / (y ^ 2.0)) + Float64(1.0 / (y ^ 4.0))))))); end return tmp end
function tmp = code(x, y) tmp = 1.0 - log((1.0 - ((x - y) / (1.0 - y)))); end
function tmp_2 = code(x, y) t_0 = (x - y) / (1.0 - y); tmp = 0.0; if (t_0 <= 0.95) tmp = 1.0 - log((1.0 - t_0)); else tmp = 1.0 - log((((x / (y ^ 2.0)) + (-1.0 * (((1.0 - x) / y) + ((1.0 + (-1.0 * x)) / (y ^ 3.0))))) + ((x / (y ^ 4.0)) - ((1.0 / (y ^ 2.0)) + (1.0 / (y ^ 4.0)))))); end tmp_2 = tmp; end
code[x_, y_] := N[(1.0 - N[Log[N[(1.0 - N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.95], N[(1.0 - N[Log[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(N[(N[(x / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 * N[(N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision] + N[(N[(1.0 + N[(-1.0 * x), $MachinePrecision]), $MachinePrecision] / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x / N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\begin{array}{l}
t_0 := \frac{x - y}{1 - y}\\
\mathbf{if}\;t_0 \leq 0.95:\\
\;\;\;\;1 - \log \left(1 - t_0\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\left(\frac{x}{{y}^{2}} + -1 \cdot \left(\frac{1 - x}{y} + \frac{1 + -1 \cdot x}{{y}^{3}}\right)\right) + \left(\frac{x}{{y}^{4}} - \left(\frac{1}{{y}^{2}} + \frac{1}{{y}^{4}}\right)\right)\right)\\
\end{array}
Results
| Original | 18.2 |
|---|---|
| Target | 0.1 |
| Herbie | 0.0 |
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 0.94999999999999996Initial program 0.0
if 0.94999999999999996 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 61.1
Taylor expanded in y around -inf 0.1
Simplified0.1
[Start]0.1 | \[ 1 - \log \left(\left(\frac{x}{{y}^{4}} + \left(\frac{x}{{y}^{2}} + \left(-1 \cdot \frac{1 + -1 \cdot x}{{y}^{3}} + -1 \cdot \frac{1 - x}{y}\right)\right)\right) - \left(\frac{1}{{y}^{2}} + \frac{1}{{y}^{4}}\right)\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-107 [=>]0.1 | \[ 1 - \log \color{blue}{\left(\left(\frac{x}{{y}^{2}} + \left(-1 \cdot \frac{1 + -1 \cdot x}{{y}^{3}} + -1 \cdot \frac{1 - x}{y}\right)\right) + \left(\frac{x}{{y}^{4}} - \left(\frac{1}{{y}^{2}} + \frac{1}{{y}^{4}}\right)\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-35 [=>]0.1 | \[ 1 - \log \left(\left(\frac{x}{{y}^{2}} + \color{blue}{\left(-1 \cdot \frac{1 - x}{y} + -1 \cdot \frac{1 + -1 \cdot x}{{y}^{3}}\right)}\right) + \left(\frac{x}{{y}^{4}} - \left(\frac{1}{{y}^{2}} + \frac{1}{{y}^{4}}\right)\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.1 | \[ 1 - \log \left(\left(\frac{x}{{y}^{2}} + \left(\color{blue}{\frac{1 - x}{y} \cdot -1} + -1 \cdot \frac{1 + -1 \cdot x}{{y}^{3}}\right)\right) + \left(\frac{x}{{y}^{4}} - \left(\frac{1}{{y}^{2}} + \frac{1}{{y}^{4}}\right)\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-23 [=>]0.1 | \[ 1 - \log \left(\left(\frac{x}{{y}^{2}} + \color{blue}{-1 \cdot \left(\frac{1 - x}{y} + \frac{1 + -1 \cdot x}{{y}^{3}}\right)}\right) + \left(\frac{x}{{y}^{4}} - \left(\frac{1}{{y}^{2}} + \frac{1}{{y}^{4}}\right)\right)\right)
\] |
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 7620 |
| Alternative 2 | |
|---|---|
| Error | 1.3 |
| Cost | 7176 |
| Alternative 3 | |
|---|---|
| Error | 12.9 |
| Cost | 6984 |
| Alternative 4 | |
|---|---|
| Error | 7.0 |
| Cost | 6984 |
| Alternative 5 | |
|---|---|
| Error | 23.4 |
| Cost | 6852 |
| Alternative 6 | |
|---|---|
| Error | 36.4 |
| Cost | 192 |
| Alternative 7 | |
|---|---|
| Error | 36.5 |
| Cost | 64 |
herbie shell --seed 2023090
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, B"
:precision binary64
:herbie-target
(if (< y -81284752.61947241) (- 1.0 (log (- (/ x (* y y)) (- (/ 1.0 y) (/ x y))))) (if (< y 3.0094271212461764e+25) (log (/ (exp 1.0) (- 1.0 (/ (- x y) (- 1.0 y))))) (- 1.0 (log (- (/ x (* y y)) (- (/ 1.0 y) (/ x y)))))))
(- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))