| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 7040 |
(FPCore (x) :precision binary64 (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (+ x 1.0)))
(t_1 (+ (+ t_0 (/ -2.0 x)) (/ 1.0 (+ x -1.0)))))
(if (<= t_1 -10.0)
(- t_0 (* (- -1.0 x) (/ (- (- -2.0 x) (* x -2.0)) (* x (- 1.0 (* x x))))))
(if (<= t_1 5e-22)
(/ 2.0 (pow x 3.0))
(+ t_0 (- (/ -2.0 x) (/ x (* x (- 1.0 x)))))))))double code(double x) {
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
double code(double x) {
double t_0 = 1.0 / (x + 1.0);
double t_1 = (t_0 + (-2.0 / x)) + (1.0 / (x + -1.0));
double tmp;
if (t_1 <= -10.0) {
tmp = t_0 - ((-1.0 - x) * (((-2.0 - x) - (x * -2.0)) / (x * (1.0 - (x * x)))));
} else if (t_1 <= 5e-22) {
tmp = 2.0 / pow(x, 3.0);
} else {
tmp = t_0 + ((-2.0 / x) - (x / (x * (1.0 - x))));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 / (x + 1.0d0)) - (2.0d0 / x)) + (1.0d0 / (x - 1.0d0))
end function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 / (x + 1.0d0)
t_1 = (t_0 + ((-2.0d0) / x)) + (1.0d0 / (x + (-1.0d0)))
if (t_1 <= (-10.0d0)) then
tmp = t_0 - (((-1.0d0) - x) * ((((-2.0d0) - x) - (x * (-2.0d0))) / (x * (1.0d0 - (x * x)))))
else if (t_1 <= 5d-22) then
tmp = 2.0d0 / (x ** 3.0d0)
else
tmp = t_0 + (((-2.0d0) / x) - (x / (x * (1.0d0 - x))))
end if
code = tmp
end function
public static double code(double x) {
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
public static double code(double x) {
double t_0 = 1.0 / (x + 1.0);
double t_1 = (t_0 + (-2.0 / x)) + (1.0 / (x + -1.0));
double tmp;
if (t_1 <= -10.0) {
tmp = t_0 - ((-1.0 - x) * (((-2.0 - x) - (x * -2.0)) / (x * (1.0 - (x * x)))));
} else if (t_1 <= 5e-22) {
tmp = 2.0 / Math.pow(x, 3.0);
} else {
tmp = t_0 + ((-2.0 / x) - (x / (x * (1.0 - x))));
}
return tmp;
}
def code(x): return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0))
def code(x): t_0 = 1.0 / (x + 1.0) t_1 = (t_0 + (-2.0 / x)) + (1.0 / (x + -1.0)) tmp = 0 if t_1 <= -10.0: tmp = t_0 - ((-1.0 - x) * (((-2.0 - x) - (x * -2.0)) / (x * (1.0 - (x * x))))) elif t_1 <= 5e-22: tmp = 2.0 / math.pow(x, 3.0) else: tmp = t_0 + ((-2.0 / x) - (x / (x * (1.0 - x)))) return tmp
function code(x) return Float64(Float64(Float64(1.0 / Float64(x + 1.0)) - Float64(2.0 / x)) + Float64(1.0 / Float64(x - 1.0))) end
function code(x) t_0 = Float64(1.0 / Float64(x + 1.0)) t_1 = Float64(Float64(t_0 + Float64(-2.0 / x)) + Float64(1.0 / Float64(x + -1.0))) tmp = 0.0 if (t_1 <= -10.0) tmp = Float64(t_0 - Float64(Float64(-1.0 - x) * Float64(Float64(Float64(-2.0 - x) - Float64(x * -2.0)) / Float64(x * Float64(1.0 - Float64(x * x)))))); elseif (t_1 <= 5e-22) tmp = Float64(2.0 / (x ^ 3.0)); else tmp = Float64(t_0 + Float64(Float64(-2.0 / x) - Float64(x / Float64(x * Float64(1.0 - x))))); end return tmp end
function tmp = code(x) tmp = ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0)); end
function tmp_2 = code(x) t_0 = 1.0 / (x + 1.0); t_1 = (t_0 + (-2.0 / x)) + (1.0 / (x + -1.0)); tmp = 0.0; if (t_1 <= -10.0) tmp = t_0 - ((-1.0 - x) * (((-2.0 - x) - (x * -2.0)) / (x * (1.0 - (x * x))))); elseif (t_1 <= 5e-22) tmp = 2.0 / (x ^ 3.0); else tmp = t_0 + ((-2.0 / x) - (x / (x * (1.0 - x)))); end tmp_2 = tmp; end
code[x_] := N[(N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + N[(-2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -10.0], N[(t$95$0 - N[(N[(-1.0 - x), $MachinePrecision] * N[(N[(N[(-2.0 - x), $MachinePrecision] - N[(x * -2.0), $MachinePrecision]), $MachinePrecision] / N[(x * N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-22], N[(2.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(N[(-2.0 / x), $MachinePrecision] - N[(x / N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\begin{array}{l}
t_0 := \frac{1}{x + 1}\\
t_1 := \left(t_0 + \frac{-2}{x}\right) + \frac{1}{x + -1}\\
\mathbf{if}\;t_1 \leq -10:\\
\;\;\;\;t_0 - \left(-1 - x\right) \cdot \frac{\left(-2 - x\right) - x \cdot -2}{x \cdot \left(1 - x \cdot x\right)}\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-22}:\\
\;\;\;\;\frac{2}{{x}^{3}}\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(\frac{-2}{x} - \frac{x}{x \cdot \left(1 - x\right)}\right)\\
\end{array}
Results
| Original | 9.7 |
|---|---|
| Target | 0.3 |
| Herbie | 0.6 |
if (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < -10Initial program 0.0
Simplified0.0
[Start]0.0 | \[ \left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\] |
|---|---|
associate-+l- [=>]0.0 | \[ \color{blue}{\frac{1}{x + 1} - \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
sub-neg [=>]0.0 | \[ \color{blue}{\frac{1}{x + 1} + \left(-\left(\frac{2}{x} - \frac{1}{x - 1}\right)\right)}
\] |
neg-mul-1 [=>]0.0 | \[ \frac{1}{x + 1} + \color{blue}{-1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
metadata-eval [<=]0.0 | \[ \frac{1}{x + 1} + \color{blue}{\left(-1\right)} \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)
\] |
cancel-sign-sub-inv [<=]0.0 | \[ \color{blue}{\frac{1}{x + 1} - 1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
+-commutative [=>]0.0 | \[ \frac{1}{\color{blue}{1 + x}} - 1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)
\] |
*-lft-identity [=>]0.0 | \[ \frac{1}{1 + x} - \color{blue}{\left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
sub-neg [=>]0.0 | \[ \frac{1}{1 + x} - \left(\frac{2}{x} - \frac{1}{\color{blue}{x + \left(-1\right)}}\right)
\] |
metadata-eval [=>]0.0 | \[ \frac{1}{1 + x} - \left(\frac{2}{x} - \frac{1}{x + \color{blue}{-1}}\right)
\] |
Applied egg-rr0.0
Simplified0.0
[Start]0.0 | \[ \frac{1}{1 + x} - \frac{\frac{-2 + \left(2 \cdot x - x\right)}{x}}{1 - x \cdot x} \cdot \left(-1 - x\right)
\] |
|---|---|
*-commutative [=>]0.0 | \[ \frac{1}{1 + x} - \color{blue}{\left(-1 - x\right) \cdot \frac{\frac{-2 + \left(2 \cdot x - x\right)}{x}}{1 - x \cdot x}}
\] |
associate-/l/ [=>]0.0 | \[ \frac{1}{1 + x} - \left(-1 - x\right) \cdot \color{blue}{\frac{-2 + \left(2 \cdot x - x\right)}{\left(1 - x \cdot x\right) \cdot x}}
\] |
+-commutative [=>]0.0 | \[ \frac{1}{1 + x} - \left(-1 - x\right) \cdot \frac{\color{blue}{\left(2 \cdot x - x\right) + -2}}{\left(1 - x \cdot x\right) \cdot x}
\] |
associate-+l- [=>]0.0 | \[ \frac{1}{1 + x} - \left(-1 - x\right) \cdot \frac{\color{blue}{2 \cdot x - \left(x - -2\right)}}{\left(1 - x \cdot x\right) \cdot x}
\] |
*-commutative [=>]0.0 | \[ \frac{1}{1 + x} - \left(-1 - x\right) \cdot \frac{\color{blue}{x \cdot 2} - \left(x - -2\right)}{\left(1 - x \cdot x\right) \cdot x}
\] |
*-commutative [=>]0.0 | \[ \frac{1}{1 + x} - \left(-1 - x\right) \cdot \frac{x \cdot 2 - \left(x - -2\right)}{\color{blue}{x \cdot \left(1 - x \cdot x\right)}}
\] |
if -10 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < 4.99999999999999954e-22Initial program 19.6
Simplified19.6
[Start]19.6 | \[ \left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\] |
|---|---|
associate-+l- [=>]19.6 | \[ \color{blue}{\frac{1}{x + 1} - \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
sub-neg [=>]19.6 | \[ \color{blue}{\frac{1}{x + 1} + \left(-\left(\frac{2}{x} - \frac{1}{x - 1}\right)\right)}
\] |
neg-mul-1 [=>]19.6 | \[ \frac{1}{x + 1} + \color{blue}{-1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
metadata-eval [<=]19.6 | \[ \frac{1}{x + 1} + \color{blue}{\left(-1\right)} \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)
\] |
cancel-sign-sub-inv [<=]19.6 | \[ \color{blue}{\frac{1}{x + 1} - 1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
+-commutative [=>]19.6 | \[ \frac{1}{\color{blue}{1 + x}} - 1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)
\] |
*-lft-identity [=>]19.6 | \[ \frac{1}{1 + x} - \color{blue}{\left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
sub-neg [=>]19.6 | \[ \frac{1}{1 + x} - \left(\frac{2}{x} - \frac{1}{\color{blue}{x + \left(-1\right)}}\right)
\] |
metadata-eval [=>]19.6 | \[ \frac{1}{1 + x} - \left(\frac{2}{x} - \frac{1}{x + \color{blue}{-1}}\right)
\] |
Taylor expanded in x around inf 0.9
if 4.99999999999999954e-22 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) Initial program 0.5
Simplified0.5
[Start]0.5 | \[ \left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\] |
|---|---|
associate-+l- [=>]0.5 | \[ \color{blue}{\frac{1}{x + 1} - \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
sub-neg [=>]0.5 | \[ \color{blue}{\frac{1}{x + 1} + \left(-\left(\frac{2}{x} - \frac{1}{x - 1}\right)\right)}
\] |
neg-mul-1 [=>]0.5 | \[ \frac{1}{x + 1} + \color{blue}{-1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
metadata-eval [<=]0.5 | \[ \frac{1}{x + 1} + \color{blue}{\left(-1\right)} \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)
\] |
cancel-sign-sub-inv [<=]0.5 | \[ \color{blue}{\frac{1}{x + 1} - 1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
+-commutative [=>]0.5 | \[ \frac{1}{\color{blue}{1 + x}} - 1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)
\] |
*-lft-identity [=>]0.5 | \[ \frac{1}{1 + x} - \color{blue}{\left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
sub-neg [=>]0.5 | \[ \frac{1}{1 + x} - \left(\frac{2}{x} - \frac{1}{\color{blue}{x + \left(-1\right)}}\right)
\] |
metadata-eval [=>]0.5 | \[ \frac{1}{1 + x} - \left(\frac{2}{x} - \frac{1}{x + \color{blue}{-1}}\right)
\] |
Applied egg-rr0.5
Simplified0.5
[Start]0.5 | \[ \left(\frac{1}{1 + x} - \frac{2}{x}\right) + \left(\mathsf{fma}\left(-\frac{2}{x}, 1, \frac{2}{x}\right) - \frac{1}{1 - x}\right)
\] |
|---|---|
sub-neg [=>]0.5 | \[ \color{blue}{\left(\frac{1}{1 + x} + \left(-\frac{2}{x}\right)\right)} + \left(\mathsf{fma}\left(-\frac{2}{x}, 1, \frac{2}{x}\right) - \frac{1}{1 - x}\right)
\] |
mul-1-neg [<=]0.5 | \[ \left(\frac{1}{1 + x} + \color{blue}{-1 \cdot \frac{2}{x}}\right) + \left(\mathsf{fma}\left(-\frac{2}{x}, 1, \frac{2}{x}\right) - \frac{1}{1 - x}\right)
\] |
associate-+l+ [=>]0.5 | \[ \color{blue}{\frac{1}{1 + x} + \left(-1 \cdot \frac{2}{x} + \left(\mathsf{fma}\left(-\frac{2}{x}, 1, \frac{2}{x}\right) - \frac{1}{1 - x}\right)\right)}
\] |
+-commutative [=>]0.5 | \[ \frac{1}{\color{blue}{x + 1}} + \left(-1 \cdot \frac{2}{x} + \left(\mathsf{fma}\left(-\frac{2}{x}, 1, \frac{2}{x}\right) - \frac{1}{1 - x}\right)\right)
\] |
associate-*r/ [=>]0.5 | \[ \frac{1}{x + 1} + \left(\color{blue}{\frac{-1 \cdot 2}{x}} + \left(\mathsf{fma}\left(-\frac{2}{x}, 1, \frac{2}{x}\right) - \frac{1}{1 - x}\right)\right)
\] |
metadata-eval [=>]0.5 | \[ \frac{1}{x + 1} + \left(\frac{\color{blue}{-2}}{x} + \left(\mathsf{fma}\left(-\frac{2}{x}, 1, \frac{2}{x}\right) - \frac{1}{1 - x}\right)\right)
\] |
mul-1-neg [<=]0.5 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \left(\mathsf{fma}\left(\color{blue}{-1 \cdot \frac{2}{x}}, 1, \frac{2}{x}\right) - \frac{1}{1 - x}\right)\right)
\] |
fma-udef [=>]0.5 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \left(\color{blue}{\left(\left(-1 \cdot \frac{2}{x}\right) \cdot 1 + \frac{2}{x}\right)} - \frac{1}{1 - x}\right)\right)
\] |
associate--l+ [=>]0.5 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \color{blue}{\left(\left(-1 \cdot \frac{2}{x}\right) \cdot 1 + \left(\frac{2}{x} - \frac{1}{1 - x}\right)\right)}\right)
\] |
associate-*r/ [=>]0.5 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \left(\color{blue}{\frac{-1 \cdot 2}{x}} \cdot 1 + \left(\frac{2}{x} - \frac{1}{1 - x}\right)\right)\right)
\] |
metadata-eval [=>]0.5 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \left(\frac{\color{blue}{-2}}{x} \cdot 1 + \left(\frac{2}{x} - \frac{1}{1 - x}\right)\right)\right)
\] |
associate-*l/ [=>]0.5 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \left(\color{blue}{\frac{-2 \cdot 1}{x}} + \left(\frac{2}{x} - \frac{1}{1 - x}\right)\right)\right)
\] |
metadata-eval [=>]0.5 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \left(\frac{\color{blue}{-2}}{x} + \left(\frac{2}{x} - \frac{1}{1 - x}\right)\right)\right)
\] |
sub-neg [=>]0.5 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \left(\frac{-2}{x} + \color{blue}{\left(\frac{2}{x} + \left(-\frac{1}{1 - x}\right)\right)}\right)\right)
\] |
distribute-neg-frac [=>]0.5 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \left(\frac{-2}{x} + \left(\frac{2}{x} + \color{blue}{\frac{-1}{1 - x}}\right)\right)\right)
\] |
metadata-eval [=>]0.5 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \left(\frac{-2}{x} + \left(\frac{2}{x} + \frac{\color{blue}{-1}}{1 - x}\right)\right)\right)
\] |
Applied egg-rr31.0
Simplified31.0
[Start]31.0 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \frac{-2 \cdot \left(x \cdot \left(1 - x\right)\right) + x \cdot \mathsf{fma}\left(2, 1 - x, -x\right)}{x \cdot \left(x \cdot \left(1 - x\right)\right)}\right)
\] |
|---|---|
+-commutative [=>]31.0 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \frac{\color{blue}{x \cdot \mathsf{fma}\left(2, 1 - x, -x\right) + -2 \cdot \left(x \cdot \left(1 - x\right)\right)}}{x \cdot \left(x \cdot \left(1 - x\right)\right)}\right)
\] |
*-commutative [<=]31.0 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \frac{x \cdot \mathsf{fma}\left(2, 1 - x, -x\right) + \color{blue}{\left(x \cdot \left(1 - x\right)\right) \cdot -2}}{x \cdot \left(x \cdot \left(1 - x\right)\right)}\right)
\] |
associate-*l* [=>]31.0 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \frac{x \cdot \mathsf{fma}\left(2, 1 - x, -x\right) + \color{blue}{x \cdot \left(\left(1 - x\right) \cdot -2\right)}}{x \cdot \left(x \cdot \left(1 - x\right)\right)}\right)
\] |
distribute-lft-out [=>]31.0 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \frac{\color{blue}{x \cdot \left(\mathsf{fma}\left(2, 1 - x, -x\right) + \left(1 - x\right) \cdot -2\right)}}{x \cdot \left(x \cdot \left(1 - x\right)\right)}\right)
\] |
fma-udef [=>]31.0 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \frac{x \cdot \left(\color{blue}{\left(2 \cdot \left(1 - x\right) + \left(-x\right)\right)} + \left(1 - x\right) \cdot -2\right)}{x \cdot \left(x \cdot \left(1 - x\right)\right)}\right)
\] |
unsub-neg [=>]31.0 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \frac{x \cdot \left(\color{blue}{\left(2 \cdot \left(1 - x\right) - x\right)} + \left(1 - x\right) \cdot -2\right)}{x \cdot \left(x \cdot \left(1 - x\right)\right)}\right)
\] |
*-commutative [=>]31.0 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \frac{x \cdot \left(\left(2 \cdot \left(1 - x\right) - x\right) + \color{blue}{-2 \cdot \left(1 - x\right)}\right)}{x \cdot \left(x \cdot \left(1 - x\right)\right)}\right)
\] |
Applied egg-rr1.4
Simplified0.5
[Start]1.4 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \left(e^{\mathsf{log1p}\left(\frac{2 \cdot \left(1 - x\right) - \mathsf{fma}\left(2, 1 - x, x\right)}{x \cdot \left(1 - x\right)}\right)} - 1\right)\right)
\] |
|---|---|
expm1-def [=>]1.2 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2 \cdot \left(1 - x\right) - \mathsf{fma}\left(2, 1 - x, x\right)}{x \cdot \left(1 - x\right)}\right)\right)}\right)
\] |
expm1-log1p [=>]0.5 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \color{blue}{\frac{2 \cdot \left(1 - x\right) - \mathsf{fma}\left(2, 1 - x, x\right)}{x \cdot \left(1 - x\right)}}\right)
\] |
fma-udef [=>]0.5 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \frac{2 \cdot \left(1 - x\right) - \color{blue}{\left(2 \cdot \left(1 - x\right) + x\right)}}{x \cdot \left(1 - x\right)}\right)
\] |
associate--r+ [=>]0.5 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \frac{\color{blue}{\left(2 \cdot \left(1 - x\right) - 2 \cdot \left(1 - x\right)\right) - x}}{x \cdot \left(1 - x\right)}\right)
\] |
+-inverses [=>]0.5 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \frac{\color{blue}{0} - x}{x \cdot \left(1 - x\right)}\right)
\] |
neg-sub0 [<=]0.5 | \[ \frac{1}{x + 1} + \left(\frac{-2}{x} + \frac{\color{blue}{-x}}{x \cdot \left(1 - x\right)}\right)
\] |
Final simplification0.6
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 7040 |
| Alternative 2 | |
|---|---|
| Error | 9.7 |
| Cost | 960 |
| Alternative 3 | |
|---|---|
| Error | 9.7 |
| Cost | 960 |
| Alternative 4 | |
|---|---|
| Error | 15.1 |
| Cost | 585 |
| Alternative 5 | |
|---|---|
| Error | 14.9 |
| Cost | 584 |
| Alternative 6 | |
|---|---|
| Error | 10.5 |
| Cost | 448 |
| Alternative 7 | |
|---|---|
| Error | 30.4 |
| Cost | 192 |
| Alternative 8 | |
|---|---|
| Error | 61.9 |
| Cost | 64 |
herbie shell --seed 2023237
(FPCore (x)
:name "3frac (problem 3.3.3)"
:precision binary64
:herbie-target
(/ 2.0 (* x (- (* x x) 1.0)))
(+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))