| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 7688 |
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
(FPCore (x y)
:precision binary64
(if (<= y -11800.0)
(+
(/ x (pow y 2.0))
(+
(* -1.0 (+ (/ (+ x -1.0) y) (/ (+ x -1.0) (pow y 3.0))))
(- x (/ 1.0 (pow y 2.0)))))
(if (<= y 360000.0)
(- 1.0 (* y (/ (- 1.0 x) (+ 1.0 y))))
(+ (/ 1.0 y) (+ (/ (+ x -1.0) (pow y 2.0)) (- x (/ x y)))))))double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
double code(double x, double y) {
double tmp;
if (y <= -11800.0) {
tmp = (x / pow(y, 2.0)) + ((-1.0 * (((x + -1.0) / y) + ((x + -1.0) / pow(y, 3.0)))) + (x - (1.0 / pow(y, 2.0))));
} else if (y <= 360000.0) {
tmp = 1.0 - (y * ((1.0 - x) / (1.0 + y)));
} else {
tmp = (1.0 / y) + (((x + -1.0) / pow(y, 2.0)) + (x - (x / y)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-11800.0d0)) then
tmp = (x / (y ** 2.0d0)) + (((-1.0d0) * (((x + (-1.0d0)) / y) + ((x + (-1.0d0)) / (y ** 3.0d0)))) + (x - (1.0d0 / (y ** 2.0d0))))
else if (y <= 360000.0d0) then
tmp = 1.0d0 - (y * ((1.0d0 - x) / (1.0d0 + y)))
else
tmp = (1.0d0 / y) + (((x + (-1.0d0)) / (y ** 2.0d0)) + (x - (x / y)))
end if
code = tmp
end function
public static double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
public static double code(double x, double y) {
double tmp;
if (y <= -11800.0) {
tmp = (x / Math.pow(y, 2.0)) + ((-1.0 * (((x + -1.0) / y) + ((x + -1.0) / Math.pow(y, 3.0)))) + (x - (1.0 / Math.pow(y, 2.0))));
} else if (y <= 360000.0) {
tmp = 1.0 - (y * ((1.0 - x) / (1.0 + y)));
} else {
tmp = (1.0 / y) + (((x + -1.0) / Math.pow(y, 2.0)) + (x - (x / y)));
}
return tmp;
}
def code(x, y): return 1.0 - (((1.0 - x) * y) / (y + 1.0))
def code(x, y): tmp = 0 if y <= -11800.0: tmp = (x / math.pow(y, 2.0)) + ((-1.0 * (((x + -1.0) / y) + ((x + -1.0) / math.pow(y, 3.0)))) + (x - (1.0 / math.pow(y, 2.0)))) elif y <= 360000.0: tmp = 1.0 - (y * ((1.0 - x) / (1.0 + y))) else: tmp = (1.0 / y) + (((x + -1.0) / math.pow(y, 2.0)) + (x - (x / y))) return tmp
function code(x, y) return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) end
function code(x, y) tmp = 0.0 if (y <= -11800.0) tmp = Float64(Float64(x / (y ^ 2.0)) + Float64(Float64(-1.0 * Float64(Float64(Float64(x + -1.0) / y) + Float64(Float64(x + -1.0) / (y ^ 3.0)))) + Float64(x - Float64(1.0 / (y ^ 2.0))))); elseif (y <= 360000.0) tmp = Float64(1.0 - Float64(y * Float64(Float64(1.0 - x) / Float64(1.0 + y)))); else tmp = Float64(Float64(1.0 / y) + Float64(Float64(Float64(x + -1.0) / (y ^ 2.0)) + Float64(x - Float64(x / y)))); end return tmp end
function tmp = code(x, y) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -11800.0) tmp = (x / (y ^ 2.0)) + ((-1.0 * (((x + -1.0) / y) + ((x + -1.0) / (y ^ 3.0)))) + (x - (1.0 / (y ^ 2.0)))); elseif (y <= 360000.0) tmp = 1.0 - (y * ((1.0 - x) / (1.0 + y))); else tmp = (1.0 / y) + (((x + -1.0) / (y ^ 2.0)) + (x - (x / y))); end tmp_2 = tmp; end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := If[LessEqual[y, -11800.0], N[(N[(x / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 * N[(N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x - N[(1.0 / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 360000.0], N[(1.0 - N[(y * N[(N[(1.0 - x), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] + N[(N[(N[(x + -1.0), $MachinePrecision] / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision] + N[(x - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\begin{array}{l}
\mathbf{if}\;y \leq -11800:\\
\;\;\;\;\frac{x}{{y}^{2}} + \left(-1 \cdot \left(\frac{x + -1}{y} + \frac{x + -1}{{y}^{3}}\right) + \left(x - \frac{1}{{y}^{2}}\right)\right)\\
\mathbf{elif}\;y \leq 360000:\\
\;\;\;\;1 - y \cdot \frac{1 - x}{1 + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} + \left(\frac{x + -1}{{y}^{2}} + \left(x - \frac{x}{y}\right)\right)\\
\end{array}
Results
| Original | 22.7 |
|---|---|
| Target | 0.2 |
| Herbie | 0.0 |
if y < -11800Initial program 45.2
Simplified28.2
[Start]45.2 | \[ 1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\] |
|---|---|
rational.json-simplify-49 [=>]28.2 | \[ 1 - \color{blue}{y \cdot \frac{1 - x}{y + 1}}
\] |
rational.json-simplify-1 [=>]28.2 | \[ 1 - y \cdot \frac{1 - x}{\color{blue}{1 + y}}
\] |
rational.json-simplify-17 [=>]28.2 | \[ 1 - y \cdot \frac{1 - x}{\color{blue}{y - -1}}
\] |
rational.json-simplify-50 [=>]28.2 | \[ 1 - y \cdot \color{blue}{\frac{-\left(1 - x\right)}{-1 - y}}
\] |
rational.json-simplify-8 [=>]28.2 | \[ 1 - y \cdot \frac{\color{blue}{\left(1 - x\right) \cdot -1}}{-1 - y}
\] |
rational.json-simplify-2 [=>]28.2 | \[ 1 - y \cdot \frac{\color{blue}{-1 \cdot \left(1 - x\right)}}{-1 - y}
\] |
rational.json-simplify-49 [=>]28.3 | \[ 1 - y \cdot \color{blue}{\left(\left(1 - x\right) \cdot \frac{-1}{-1 - y}\right)}
\] |
rational.json-simplify-2 [=>]28.3 | \[ 1 - y \cdot \color{blue}{\left(\frac{-1}{-1 - y} \cdot \left(1 - x\right)\right)}
\] |
rational.json-simplify-2 [<=]28.3 | \[ 1 - y \cdot \color{blue}{\left(\left(1 - x\right) \cdot \frac{-1}{-1 - y}\right)}
\] |
rational.json-simplify-49 [<=]28.2 | \[ 1 - y \cdot \color{blue}{\frac{-1 \cdot \left(1 - x\right)}{-1 - y}}
\] |
rational.json-simplify-2 [<=]28.2 | \[ 1 - y \cdot \frac{\color{blue}{\left(1 - x\right) \cdot -1}}{-1 - y}
\] |
rational.json-simplify-8 [<=]28.2 | \[ 1 - y \cdot \frac{\color{blue}{-\left(1 - x\right)}}{-1 - y}
\] |
rational.json-simplify-50 [<=]28.2 | \[ 1 - y \cdot \color{blue}{\frac{1 - x}{y - -1}}
\] |
rational.json-simplify-17 [<=]28.2 | \[ 1 - y \cdot \frac{1 - x}{\color{blue}{1 + y}}
\] |
Taylor expanded in y around -inf 0.0
Simplified0.0
[Start]0.0 | \[ \left(\frac{x}{{y}^{2}} + \left(-1 \cdot \frac{x - 1}{y} + \left(-1 \cdot \frac{x - 1}{{y}^{3}} + x\right)\right)\right) - \frac{1}{{y}^{2}}
\] |
|---|---|
rational.json-simplify-1 [=>]0.0 | \[ \color{blue}{\left(\left(-1 \cdot \frac{x - 1}{y} + \left(-1 \cdot \frac{x - 1}{{y}^{3}} + x\right)\right) + \frac{x}{{y}^{2}}\right)} - \frac{1}{{y}^{2}}
\] |
rational.json-simplify-48 [=>]0.0 | \[ \color{blue}{\frac{x}{{y}^{2}} + \left(\left(-1 \cdot \frac{x - 1}{y} + \left(-1 \cdot \frac{x - 1}{{y}^{3}} + x\right)\right) - \frac{1}{{y}^{2}}\right)}
\] |
rational.json-simplify-41 [<=]0.0 | \[ \frac{x}{{y}^{2}} + \left(\color{blue}{\left(x + \left(-1 \cdot \frac{x - 1}{y} + -1 \cdot \frac{x - 1}{{y}^{3}}\right)\right)} - \frac{1}{{y}^{2}}\right)
\] |
rational.json-simplify-48 [=>]0.0 | \[ \frac{x}{{y}^{2}} + \color{blue}{\left(\left(-1 \cdot \frac{x - 1}{y} + -1 \cdot \frac{x - 1}{{y}^{3}}\right) + \left(x - \frac{1}{{y}^{2}}\right)\right)}
\] |
rational.json-simplify-1 [=>]0.0 | \[ \frac{x}{{y}^{2}} + \left(\color{blue}{\left(-1 \cdot \frac{x - 1}{{y}^{3}} + -1 \cdot \frac{x - 1}{y}\right)} + \left(x - \frac{1}{{y}^{2}}\right)\right)
\] |
rational.json-simplify-2 [=>]0.0 | \[ \frac{x}{{y}^{2}} + \left(\left(-1 \cdot \frac{x - 1}{{y}^{3}} + \color{blue}{\frac{x - 1}{y} \cdot -1}\right) + \left(x - \frac{1}{{y}^{2}}\right)\right)
\] |
rational.json-simplify-51 [=>]0.0 | \[ \frac{x}{{y}^{2}} + \left(\color{blue}{-1 \cdot \left(\frac{x - 1}{y} + \frac{x - 1}{{y}^{3}}\right)} + \left(x - \frac{1}{{y}^{2}}\right)\right)
\] |
rational.json-simplify-15 [<=]0.0 | \[ \frac{x}{{y}^{2}} + \left(-1 \cdot \left(\frac{\color{blue}{x + -1}}{y} + \frac{x - 1}{{y}^{3}}\right) + \left(x - \frac{1}{{y}^{2}}\right)\right)
\] |
rational.json-simplify-15 [<=]0.0 | \[ \frac{x}{{y}^{2}} + \left(-1 \cdot \left(\frac{x + -1}{y} + \frac{\color{blue}{x + -1}}{{y}^{3}}\right) + \left(x - \frac{1}{{y}^{2}}\right)\right)
\] |
if -11800 < y < 3.6e5Initial program 0.0
Simplified0.1
[Start]0.0 | \[ 1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\] |
|---|---|
rational.json-simplify-49 [=>]0.1 | \[ 1 - \color{blue}{y \cdot \frac{1 - x}{y + 1}}
\] |
rational.json-simplify-1 [=>]0.1 | \[ 1 - y \cdot \frac{1 - x}{\color{blue}{1 + y}}
\] |
rational.json-simplify-17 [=>]0.1 | \[ 1 - y \cdot \frac{1 - x}{\color{blue}{y - -1}}
\] |
rational.json-simplify-50 [=>]0.1 | \[ 1 - y \cdot \color{blue}{\frac{-\left(1 - x\right)}{-1 - y}}
\] |
rational.json-simplify-8 [=>]0.1 | \[ 1 - y \cdot \frac{\color{blue}{\left(1 - x\right) \cdot -1}}{-1 - y}
\] |
rational.json-simplify-2 [=>]0.1 | \[ 1 - y \cdot \frac{\color{blue}{-1 \cdot \left(1 - x\right)}}{-1 - y}
\] |
rational.json-simplify-49 [=>]0.1 | \[ 1 - y \cdot \color{blue}{\left(\left(1 - x\right) \cdot \frac{-1}{-1 - y}\right)}
\] |
rational.json-simplify-2 [=>]0.1 | \[ 1 - y \cdot \color{blue}{\left(\frac{-1}{-1 - y} \cdot \left(1 - x\right)\right)}
\] |
rational.json-simplify-2 [<=]0.1 | \[ 1 - y \cdot \color{blue}{\left(\left(1 - x\right) \cdot \frac{-1}{-1 - y}\right)}
\] |
rational.json-simplify-49 [<=]0.1 | \[ 1 - y \cdot \color{blue}{\frac{-1 \cdot \left(1 - x\right)}{-1 - y}}
\] |
rational.json-simplify-2 [<=]0.1 | \[ 1 - y \cdot \frac{\color{blue}{\left(1 - x\right) \cdot -1}}{-1 - y}
\] |
rational.json-simplify-8 [<=]0.1 | \[ 1 - y \cdot \frac{\color{blue}{-\left(1 - x\right)}}{-1 - y}
\] |
rational.json-simplify-50 [<=]0.1 | \[ 1 - y \cdot \color{blue}{\frac{1 - x}{y - -1}}
\] |
rational.json-simplify-17 [<=]0.1 | \[ 1 - y \cdot \frac{1 - x}{\color{blue}{1 + y}}
\] |
if 3.6e5 < y Initial program 46.1
Simplified28.9
[Start]46.1 | \[ 1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\] |
|---|---|
rational.json-simplify-2 [=>]46.1 | \[ 1 - \frac{\color{blue}{y \cdot \left(1 - x\right)}}{y + 1}
\] |
rational.json-simplify-49 [=>]28.9 | \[ 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}}
\] |
rational.json-simplify-2 [=>]28.9 | \[ 1 - \color{blue}{\frac{y}{y + 1} \cdot \left(1 - x\right)}
\] |
rational.json-simplify-35 [=>]28.9 | \[ 1 - \color{blue}{\frac{y + y}{\left(y + 1\right) + \left(y + 1\right)}} \cdot \left(1 - x\right)
\] |
rational.json-simplify-7 [<=]28.9 | \[ 1 - \frac{y + y}{\color{blue}{\frac{\left(y + 1\right) + \left(y + 1\right)}{1}}} \cdot \left(1 - x\right)
\] |
rational.json-simplify-61 [=>]28.9 | \[ 1 - \color{blue}{\frac{1}{\frac{\left(y + 1\right) + \left(y + 1\right)}{y + y}}} \cdot \left(1 - x\right)
\] |
rational.json-simplify-7 [<=]28.9 | \[ 1 - \frac{1}{\frac{\left(y + 1\right) + \left(y + 1\right)}{y + y}} \cdot \color{blue}{\frac{1 - x}{1}}
\] |
rational.json-simplify-55 [=>]28.9 | \[ 1 - \color{blue}{\frac{\frac{1 - x}{1}}{\frac{\frac{\left(y + 1\right) + \left(y + 1\right)}{y + y}}{1}}}
\] |
rational.json-simplify-7 [=>]28.9 | \[ 1 - \frac{\color{blue}{1 - x}}{\frac{\frac{\left(y + 1\right) + \left(y + 1\right)}{y + y}}{1}}
\] |
rational.json-simplify-7 [=>]28.9 | \[ 1 - \frac{1 - x}{\color{blue}{\frac{\left(y + 1\right) + \left(y + 1\right)}{y + y}}}
\] |
rational.json-simplify-36 [=>]28.9 | \[ 1 - \frac{1 - x}{\color{blue}{\frac{y + 1}{y}}}
\] |
rational.json-simplify-5 [<=]28.9 | \[ 1 - \frac{1 - x}{\frac{y + 1}{\color{blue}{y - 0}}}
\] |
rational.json-simplify-50 [=>]28.9 | \[ 1 - \frac{1 - x}{\color{blue}{\frac{-\left(y + 1\right)}{0 - y}}}
\] |
rational.json-simplify-12 [=>]28.9 | \[ 1 - \frac{1 - x}{\frac{\color{blue}{0 - \left(y + 1\right)}}{0 - y}}
\] |
rational.json-simplify-1 [=>]28.9 | \[ 1 - \frac{1 - x}{\frac{0 - \color{blue}{\left(1 + y\right)}}{0 - y}}
\] |
rational.json-simplify-17 [=>]28.9 | \[ 1 - \frac{1 - x}{\frac{0 - \color{blue}{\left(y - -1\right)}}{0 - y}}
\] |
rational.json-simplify-45 [<=]28.9 | \[ 1 - \frac{1 - x}{\frac{\color{blue}{-1 - \left(y - 0\right)}}{0 - y}}
\] |
rational.json-simplify-5 [=>]28.9 | \[ 1 - \frac{1 - x}{\frac{-1 - \color{blue}{y}}{0 - y}}
\] |
rational.json-simplify-12 [<=]28.9 | \[ 1 - \frac{1 - x}{\frac{-1 - y}{\color{blue}{-y}}}
\] |
rational.json-simplify-8 [=>]28.9 | \[ 1 - \frac{1 - x}{\frac{-1 - y}{\color{blue}{y \cdot -1}}}
\] |
rational.json-simplify-2 [=>]28.9 | \[ 1 - \frac{1 - x}{\frac{-1 - y}{\color{blue}{-1 \cdot y}}}
\] |
rational.json-simplify-25 [=>]28.9 | \[ 1 - \frac{1 - x}{\color{blue}{\frac{-1}{-1} + \frac{1}{y}}}
\] |
metadata-eval [=>]28.9 | \[ 1 - \frac{1 - x}{\color{blue}{1} + \frac{1}{y}}
\] |
Taylor expanded in y around inf 0.0
Simplified0.0
[Start]0.0 | \[ \left(\frac{1}{y} + \left(-1 \cdot \frac{1 + -1 \cdot x}{{y}^{2}} + x\right)\right) - \frac{x}{y}
\] |
|---|---|
rational.json-simplify-1 [=>]0.0 | \[ \color{blue}{\left(\left(-1 \cdot \frac{1 + -1 \cdot x}{{y}^{2}} + x\right) + \frac{1}{y}\right)} - \frac{x}{y}
\] |
rational.json-simplify-48 [=>]0.0 | \[ \color{blue}{\frac{1}{y} + \left(\left(-1 \cdot \frac{1 + -1 \cdot x}{{y}^{2}} + x\right) - \frac{x}{y}\right)}
\] |
rational.json-simplify-1 [=>]0.0 | \[ \frac{1}{y} + \left(\color{blue}{\left(x + -1 \cdot \frac{1 + -1 \cdot x}{{y}^{2}}\right)} - \frac{x}{y}\right)
\] |
rational.json-simplify-48 [=>]0.0 | \[ \frac{1}{y} + \color{blue}{\left(-1 \cdot \frac{1 + -1 \cdot x}{{y}^{2}} + \left(x - \frac{x}{y}\right)\right)}
\] |
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 7688 |
| Alternative 2 | |
|---|---|
| Error | 0.1 |
| Cost | 968 |
| Alternative 3 | |
|---|---|
| Error | 0.1 |
| Cost | 968 |
| Alternative 4 | |
|---|---|
| Error | 8.9 |
| Cost | 780 |
| Alternative 5 | |
|---|---|
| Error | 1.1 |
| Cost | 712 |
| Alternative 6 | |
|---|---|
| Error | 1.0 |
| Cost | 712 |
| Alternative 7 | |
|---|---|
| Error | 15.9 |
| Cost | 588 |
| Alternative 8 | |
|---|---|
| Error | 15.6 |
| Cost | 456 |
| Alternative 9 | |
|---|---|
| Error | 15.7 |
| Cost | 328 |
| Alternative 10 | |
|---|---|
| Error | 39.0 |
| Cost | 64 |
herbie shell --seed 2023064
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D"
:precision binary64
:herbie-target
(if (< y -3693.8482788297247) (- (/ 1.0 y) (- (/ x y) x)) (if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) (- (/ 1.0 y) (- (/ x y) x))))
(- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))