| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 15432 |
(FPCore (x y) :precision binary64 (- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))
(FPCore (x y)
:precision binary64
(if (<= y -650000.0)
(- 1.0 (log (- (+ (/ x (pow y 2.0)) (/ (+ -1.0 x) y)) (/ 1.0 (pow y 2.0)))))
(if (<= y 0.135)
(/
(+
(+
2.0
(-
(log
(+
(/ (- x y) (+ (+ y y) -2.0))
(/ (+ 2.0 (/ (- x y) (+ y -1.0))) 2.0)))))
(- (log (- 1.0 (/ (- x y) (- 1.0 y))))))
2.0)
(- 1.0 (log (/ x (+ -1.0 y)))))))double code(double x, double y) {
return 1.0 - log((1.0 - ((x - y) / (1.0 - y))));
}
double code(double x, double y) {
double tmp;
if (y <= -650000.0) {
tmp = 1.0 - log((((x / pow(y, 2.0)) + ((-1.0 + x) / y)) - (1.0 / pow(y, 2.0))));
} else if (y <= 0.135) {
tmp = ((2.0 + -log((((x - y) / ((y + y) + -2.0)) + ((2.0 + ((x - y) / (y + -1.0))) / 2.0)))) + -log((1.0 - ((x - y) / (1.0 - y))))) / 2.0;
} else {
tmp = 1.0 - log((x / (-1.0 + y)));
}
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) :: tmp
if (y <= (-650000.0d0)) then
tmp = 1.0d0 - log((((x / (y ** 2.0d0)) + (((-1.0d0) + x) / y)) - (1.0d0 / (y ** 2.0d0))))
else if (y <= 0.135d0) then
tmp = ((2.0d0 + -log((((x - y) / ((y + y) + (-2.0d0))) + ((2.0d0 + ((x - y) / (y + (-1.0d0)))) / 2.0d0)))) + -log((1.0d0 - ((x - y) / (1.0d0 - y))))) / 2.0d0
else
tmp = 1.0d0 - log((x / ((-1.0d0) + y)))
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 tmp;
if (y <= -650000.0) {
tmp = 1.0 - Math.log((((x / Math.pow(y, 2.0)) + ((-1.0 + x) / y)) - (1.0 / Math.pow(y, 2.0))));
} else if (y <= 0.135) {
tmp = ((2.0 + -Math.log((((x - y) / ((y + y) + -2.0)) + ((2.0 + ((x - y) / (y + -1.0))) / 2.0)))) + -Math.log((1.0 - ((x - y) / (1.0 - y))))) / 2.0;
} else {
tmp = 1.0 - Math.log((x / (-1.0 + y)));
}
return tmp;
}
def code(x, y): return 1.0 - math.log((1.0 - ((x - y) / (1.0 - y))))
def code(x, y): tmp = 0 if y <= -650000.0: tmp = 1.0 - math.log((((x / math.pow(y, 2.0)) + ((-1.0 + x) / y)) - (1.0 / math.pow(y, 2.0)))) elif y <= 0.135: tmp = ((2.0 + -math.log((((x - y) / ((y + y) + -2.0)) + ((2.0 + ((x - y) / (y + -1.0))) / 2.0)))) + -math.log((1.0 - ((x - y) / (1.0 - y))))) / 2.0 else: tmp = 1.0 - math.log((x / (-1.0 + y))) 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) tmp = 0.0 if (y <= -650000.0) tmp = Float64(1.0 - log(Float64(Float64(Float64(x / (y ^ 2.0)) + Float64(Float64(-1.0 + x) / y)) - Float64(1.0 / (y ^ 2.0))))); elseif (y <= 0.135) tmp = Float64(Float64(Float64(2.0 + Float64(-log(Float64(Float64(Float64(x - y) / Float64(Float64(y + y) + -2.0)) + Float64(Float64(2.0 + Float64(Float64(x - y) / Float64(y + -1.0))) / 2.0))))) + Float64(-log(Float64(1.0 - Float64(Float64(x - y) / Float64(1.0 - y)))))) / 2.0); else tmp = Float64(1.0 - log(Float64(x / Float64(-1.0 + y)))); 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) tmp = 0.0; if (y <= -650000.0) tmp = 1.0 - log((((x / (y ^ 2.0)) + ((-1.0 + x) / y)) - (1.0 / (y ^ 2.0)))); elseif (y <= 0.135) tmp = ((2.0 + -log((((x - y) / ((y + y) + -2.0)) + ((2.0 + ((x - y) / (y + -1.0))) / 2.0)))) + -log((1.0 - ((x - y) / (1.0 - y))))) / 2.0; else tmp = 1.0 - log((x / (-1.0 + y))); 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_] := If[LessEqual[y, -650000.0], N[(1.0 - N[Log[N[(N[(N[(x / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 + x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.135], N[(N[(N[(2.0 + (-N[Log[N[(N[(N[(x - y), $MachinePrecision] / N[(N[(y + y), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 + N[(N[(x - y), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] + (-N[Log[N[(1.0 - N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / 2.0), $MachinePrecision], N[(1.0 - N[Log[N[(x / N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\begin{array}{l}
\mathbf{if}\;y \leq -650000:\\
\;\;\;\;1 - \log \left(\left(\frac{x}{{y}^{2}} + \frac{-1 + x}{y}\right) - \frac{1}{{y}^{2}}\right)\\
\mathbf{elif}\;y \leq 0.135:\\
\;\;\;\;\frac{\left(2 + \left(-\log \left(\frac{x - y}{\left(y + y\right) + -2} + \frac{2 + \frac{x - y}{y + -1}}{2}\right)\right)\right) + \left(-\log \left(1 - \frac{x - y}{1 - y}\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x}{-1 + y}\right)\\
\end{array}
Results
| Original | 17.9 |
|---|---|
| Target | 0.1 |
| Herbie | 0.1 |
if y < -6.5e5Initial program 51.3
Taylor expanded in y around -inf 0.0
Simplified0.0
[Start]0.0 | \[ 1 - \log \left(\left(\frac{x}{{y}^{2}} + -1 \cdot \frac{1 - x}{y}\right) - \frac{1}{{y}^{2}}\right)
\] |
|---|---|
rational_best-simplify-62 [=>]0.0 | \[ 1 - \log \left(\left(\frac{x}{{y}^{2}} + \color{blue}{\frac{\left(1 - x\right) \cdot -1}{y}}\right) - \frac{1}{{y}^{2}}\right)
\] |
metadata-eval [<=]0.0 | \[ 1 - \log \left(\left(\frac{x}{{y}^{2}} + \frac{\left(1 - x\right) \cdot \color{blue}{\left(-1\right)}}{y}\right) - \frac{1}{{y}^{2}}\right)
\] |
rational_best-simplify-68 [<=]0.0 | \[ 1 - \log \left(\left(\frac{x}{{y}^{2}} + \frac{\color{blue}{1 \cdot \left(x - 1\right)}}{y}\right) - \frac{1}{{y}^{2}}\right)
\] |
rational_best-simplify-1 [=>]0.0 | \[ 1 - \log \left(\left(\frac{x}{{y}^{2}} + \frac{\color{blue}{\left(x - 1\right) \cdot 1}}{y}\right) - \frac{1}{{y}^{2}}\right)
\] |
rational_best-simplify-7 [=>]0.0 | \[ 1 - \log \left(\left(\frac{x}{{y}^{2}} + \frac{\color{blue}{x - 1}}{y}\right) - \frac{1}{{y}^{2}}\right)
\] |
rational_best-simplify-18 [=>]0.0 | \[ 1 - \log \left(\left(\frac{x}{{y}^{2}} + \frac{\color{blue}{x + -1}}{y}\right) - \frac{1}{{y}^{2}}\right)
\] |
rational_best-simplify-3 [=>]0.0 | \[ 1 - \log \left(\left(\frac{x}{{y}^{2}} + \frac{\color{blue}{-1 + x}}{y}\right) - \frac{1}{{y}^{2}}\right)
\] |
if -6.5e5 < y < 0.13500000000000001Initial program 0.0
Applied egg-rr0.1
Simplified0.1
[Start]0.1 | \[ \frac{-\log \left(1 - \frac{x - y}{1 - y}\right)}{2} + \frac{2 + \left(-\log \left(1 - \frac{x - y}{1 - y}\right)\right)}{2}
\] |
|---|---|
rational_best-simplify-3 [<=]0.1 | \[ \color{blue}{\frac{2 + \left(-\log \left(1 - \frac{x - y}{1 - y}\right)\right)}{2} + \frac{-\log \left(1 - \frac{x - y}{1 - y}\right)}{2}}
\] |
rational_best-simplify-76 [=>]0.1 | \[ \color{blue}{\frac{\left(2 + \left(-\log \left(1 - \frac{x - y}{1 - y}\right)\right)\right) + \left(-\log \left(1 - \frac{x - y}{1 - y}\right)\right)}{2}}
\] |
Applied egg-rr0.1
if 0.13500000000000001 < y Initial program 29.5
Taylor expanded in x around inf 0.9
Simplified0.9
[Start]0.9 | \[ 1 - \log \left(-1 \cdot \frac{x}{1 - y}\right)
\] |
|---|---|
rational_best-simplify-62 [=>]0.9 | \[ 1 - \log \color{blue}{\left(\frac{x \cdot -1}{1 - y}\right)}
\] |
rational_best-simplify-10 [=>]0.9 | \[ 1 - \log \left(\frac{\color{blue}{-x}}{1 - y}\right)
\] |
Taylor expanded in x around 0 0.9
Simplified0.9
[Start]0.9 | \[ 1 - \log \left(-1 \cdot \frac{x}{1 - y}\right)
\] |
|---|---|
rational_best-simplify-1 [<=]0.9 | \[ 1 - \log \color{blue}{\left(\frac{x}{1 - y} \cdot -1\right)}
\] |
rational_best-simplify-10 [=>]0.9 | \[ 1 - \log \color{blue}{\left(-\frac{x}{1 - y}\right)}
\] |
rational_best-simplify-13 [=>]0.9 | \[ 1 - \log \color{blue}{\left(\frac{\frac{x}{1 - y}}{-1}\right)}
\] |
rational_best-simplify-59 [=>]0.9 | \[ 1 - \log \color{blue}{\left(\frac{x}{\left(1 - y\right) \cdot -1}\right)}
\] |
rational_best-simplify-11 [<=]0.9 | \[ 1 - \log \left(\frac{x}{\color{blue}{-\left(1 - y\right)}}\right)
\] |
rational_best-simplify-14 [=>]0.9 | \[ 1 - \log \left(\frac{x}{\color{blue}{0 - \left(1 - y\right)}}\right)
\] |
rational_best-simplify-55 [=>]0.9 | \[ 1 - \log \left(\frac{x}{\color{blue}{y - \left(1 - 0\right)}}\right)
\] |
metadata-eval [=>]0.9 | \[ 1 - \log \left(\frac{x}{y - \color{blue}{1}}\right)
\] |
rational_best-simplify-19 [<=]0.9 | \[ 1 - \log \left(\frac{x}{\color{blue}{y + -1}}\right)
\] |
rational_best-simplify-3 [=>]0.9 | \[ 1 - \log \left(\frac{x}{\color{blue}{-1 + y}}\right)
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 15432 |
| Alternative 2 | |
|---|---|
| Error | 0.2 |
| Cost | 7752 |
| Alternative 3 | |
|---|---|
| Error | 0.2 |
| Cost | 7368 |
| Alternative 4 | |
|---|---|
| Error | 6.7 |
| Cost | 7112 |
| Alternative 5 | |
|---|---|
| Error | 0.9 |
| Cost | 7112 |
| Alternative 6 | |
|---|---|
| Error | 6.9 |
| Cost | 6984 |
| Alternative 7 | |
|---|---|
| Error | 13.2 |
| Cost | 6852 |
| Alternative 8 | |
|---|---|
| Error | 23.8 |
| Cost | 6788 |
| Alternative 9 | |
|---|---|
| Error | 23.5 |
| Cost | 6720 |
| Alternative 10 | |
|---|---|
| Error | 36.1 |
| Cost | 192 |
| Alternative 11 | |
|---|---|
| Error | 36.3 |
| Cost | 64 |
herbie shell --seed 2023101
(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))))))