| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 3528 |
(FPCore (x) :precision binary64 (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
(FPCore (x)
:precision binary64
(let* ((t_0 (* x (+ x -1.0)))
(t_1 (+ (+ (/ 1.0 (+ 1.0 x)) (/ -2.0 x)) (/ 1.0 (+ x -1.0)))))
(if (<= t_1 -5e-12)
(/ (/ (+ t_0 (* (+ 1.0 x) (- 2.0 x))) (+ 1.0 x)) t_0)
(if (<= t_1 0.0)
(* 2.0 (pow x -3.0))
(/
(+ (* x (- 1.0 x)) (* (+ 1.0 x) (+ x -2.0)))
(* x (* (+ 1.0 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 = x * (x + -1.0);
double t_1 = ((1.0 / (1.0 + x)) + (-2.0 / x)) + (1.0 / (x + -1.0));
double tmp;
if (t_1 <= -5e-12) {
tmp = ((t_0 + ((1.0 + x) * (2.0 - x))) / (1.0 + x)) / t_0;
} else if (t_1 <= 0.0) {
tmp = 2.0 * pow(x, -3.0);
} else {
tmp = ((x * (1.0 - x)) + ((1.0 + x) * (x + -2.0))) / (x * ((1.0 + 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 = x * (x + (-1.0d0))
t_1 = ((1.0d0 / (1.0d0 + x)) + ((-2.0d0) / x)) + (1.0d0 / (x + (-1.0d0)))
if (t_1 <= (-5d-12)) then
tmp = ((t_0 + ((1.0d0 + x) * (2.0d0 - x))) / (1.0d0 + x)) / t_0
else if (t_1 <= 0.0d0) then
tmp = 2.0d0 * (x ** (-3.0d0))
else
tmp = ((x * (1.0d0 - x)) + ((1.0d0 + x) * (x + (-2.0d0)))) / (x * ((1.0d0 + 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 = x * (x + -1.0);
double t_1 = ((1.0 / (1.0 + x)) + (-2.0 / x)) + (1.0 / (x + -1.0));
double tmp;
if (t_1 <= -5e-12) {
tmp = ((t_0 + ((1.0 + x) * (2.0 - x))) / (1.0 + x)) / t_0;
} else if (t_1 <= 0.0) {
tmp = 2.0 * Math.pow(x, -3.0);
} else {
tmp = ((x * (1.0 - x)) + ((1.0 + x) * (x + -2.0))) / (x * ((1.0 + 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 = x * (x + -1.0) t_1 = ((1.0 / (1.0 + x)) + (-2.0 / x)) + (1.0 / (x + -1.0)) tmp = 0 if t_1 <= -5e-12: tmp = ((t_0 + ((1.0 + x) * (2.0 - x))) / (1.0 + x)) / t_0 elif t_1 <= 0.0: tmp = 2.0 * math.pow(x, -3.0) else: tmp = ((x * (1.0 - x)) + ((1.0 + x) * (x + -2.0))) / (x * ((1.0 + 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(x * Float64(x + -1.0)) t_1 = Float64(Float64(Float64(1.0 / Float64(1.0 + x)) + Float64(-2.0 / x)) + Float64(1.0 / Float64(x + -1.0))) tmp = 0.0 if (t_1 <= -5e-12) tmp = Float64(Float64(Float64(t_0 + Float64(Float64(1.0 + x) * Float64(2.0 - x))) / Float64(1.0 + x)) / t_0); elseif (t_1 <= 0.0) tmp = Float64(2.0 * (x ^ -3.0)); else tmp = Float64(Float64(Float64(x * Float64(1.0 - x)) + Float64(Float64(1.0 + x) * Float64(x + -2.0))) / Float64(x * Float64(Float64(1.0 + 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 = x * (x + -1.0); t_1 = ((1.0 / (1.0 + x)) + (-2.0 / x)) + (1.0 / (x + -1.0)); tmp = 0.0; if (t_1 <= -5e-12) tmp = ((t_0 + ((1.0 + x) * (2.0 - x))) / (1.0 + x)) / t_0; elseif (t_1 <= 0.0) tmp = 2.0 * (x ^ -3.0); else tmp = ((x * (1.0 - x)) + ((1.0 + x) * (x + -2.0))) / (x * ((1.0 + 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[(x * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] + N[(-2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-12], N[(N[(N[(t$95$0 + N[(N[(1.0 + x), $MachinePrecision] * N[(2.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(2.0 * N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + x), $MachinePrecision] * N[(x + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * N[(N[(1.0 + x), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\begin{array}{l}
t_0 := x \cdot \left(x + -1\right)\\
t_1 := \left(\frac{1}{1 + x} + \frac{-2}{x}\right) + \frac{1}{x + -1}\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\frac{t_0 + \left(1 + x\right) \cdot \left(2 - x\right)}{1 + x}}{t_0}\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;2 \cdot {x}^{-3}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(1 - x\right) + \left(1 + x\right) \cdot \left(x + -2\right)}{x \cdot \left(\left(1 + x\right) \cdot \left(1 - x\right)\right)}\\
\end{array}
Results
| Original | 9.7 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
if (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < -4.9999999999999997e-12Initial program 0.1
Simplified0.1
[Start]0.1 | \[ \left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\] |
|---|---|
associate-+l- [=>]0.1 | \[ \color{blue}{\frac{1}{x + 1} - \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
sub-neg [=>]0.1 | \[ \color{blue}{\frac{1}{x + 1} + \left(-\left(\frac{2}{x} - \frac{1}{x - 1}\right)\right)}
\] |
neg-mul-1 [=>]0.1 | \[ \frac{1}{x + 1} + \color{blue}{-1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
metadata-eval [<=]0.1 | \[ \frac{1}{x + 1} + \color{blue}{\left(-1\right)} \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)
\] |
cancel-sign-sub-inv [<=]0.1 | \[ \color{blue}{\frac{1}{x + 1} - 1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
+-commutative [=>]0.1 | \[ \frac{1}{\color{blue}{1 + x}} - 1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)
\] |
*-lft-identity [=>]0.1 | \[ \frac{1}{1 + x} - \color{blue}{\left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
sub-neg [=>]0.1 | \[ \frac{1}{1 + x} - \left(\frac{2}{x} - \frac{1}{\color{blue}{x + \left(-1\right)}}\right)
\] |
metadata-eval [=>]0.1 | \[ \frac{1}{1 + x} - \left(\frac{2}{x} - \frac{1}{x + \color{blue}{-1}}\right)
\] |
Applied egg-rr0.1
Simplified0.1
[Start]0.1 | \[ \frac{1}{1 + x} - \frac{\frac{-2 + \left(2 \cdot x - x\right)}{x}}{1} \cdot \frac{1}{x + -1}
\] |
|---|---|
*-commutative [=>]0.1 | \[ \frac{1}{1 + x} - \color{blue}{\frac{1}{x + -1} \cdot \frac{\frac{-2 + \left(2 \cdot x - x\right)}{x}}{1}}
\] |
/-rgt-identity [=>]0.1 | \[ \frac{1}{1 + x} - \frac{1}{x + -1} \cdot \color{blue}{\frac{-2 + \left(2 \cdot x - x\right)}{x}}
\] |
associate-*r/ [=>]0.1 | \[ \frac{1}{1 + x} - \color{blue}{\frac{\frac{1}{x + -1} \cdot \left(-2 + \left(2 \cdot x - x\right)\right)}{x}}
\] |
*-commutative [=>]0.1 | \[ \frac{1}{1 + x} - \frac{\frac{1}{x + -1} \cdot \left(-2 + \left(\color{blue}{x \cdot 2} - x\right)\right)}{x}
\] |
Applied egg-rr0.1
Simplified0.1
[Start]0.1 | \[ \frac{1}{1 + x} + \left(-\frac{\frac{1}{x + -1} \cdot \left(-2 + \left(x \cdot 2 - x\right)\right)}{x}\right)
\] |
|---|---|
sub-neg [<=]0.1 | \[ \color{blue}{\frac{1}{1 + x} - \frac{\frac{1}{x + -1} \cdot \left(-2 + \left(x \cdot 2 - x\right)\right)}{x}}
\] |
associate-*l/ [<=]0.1 | \[ \frac{1}{1 + x} - \color{blue}{\frac{\frac{1}{x + -1}}{x} \cdot \left(-2 + \left(x \cdot 2 - x\right)\right)}
\] |
+-commutative [=>]0.1 | \[ \frac{1}{\color{blue}{x + 1}} - \frac{\frac{1}{x + -1}}{x} \cdot \left(-2 + \left(x \cdot 2 - x\right)\right)
\] |
associate-/l/ [=>]0.1 | \[ \frac{1}{x + 1} - \color{blue}{\frac{1}{x \cdot \left(x + -1\right)}} \cdot \left(-2 + \left(x \cdot 2 - x\right)\right)
\] |
associate-*l/ [=>]0.1 | \[ \frac{1}{x + 1} - \color{blue}{\frac{1 \cdot \left(-2 + \left(x \cdot 2 - x\right)\right)}{x \cdot \left(x + -1\right)}}
\] |
*-lft-identity [=>]0.1 | \[ \frac{1}{x + 1} - \frac{\color{blue}{-2 + \left(x \cdot 2 - x\right)}}{x \cdot \left(x + -1\right)}
\] |
sub-neg [=>]0.1 | \[ \frac{1}{x + 1} - \frac{-2 + \color{blue}{\left(x \cdot 2 + \left(-x\right)\right)}}{x \cdot \left(x + -1\right)}
\] |
*-commutative [=>]0.1 | \[ \frac{1}{x + 1} - \frac{-2 + \left(\color{blue}{2 \cdot x} + \left(-x\right)\right)}{x \cdot \left(x + -1\right)}
\] |
neg-mul-1 [=>]0.1 | \[ \frac{1}{x + 1} - \frac{-2 + \left(2 \cdot x + \color{blue}{-1 \cdot x}\right)}{x \cdot \left(x + -1\right)}
\] |
distribute-rgt-out [=>]0.1 | \[ \frac{1}{x + 1} - \frac{-2 + \color{blue}{x \cdot \left(2 + -1\right)}}{x \cdot \left(x + -1\right)}
\] |
metadata-eval [=>]0.1 | \[ \frac{1}{x + 1} - \frac{-2 + x \cdot \color{blue}{1}}{x \cdot \left(x + -1\right)}
\] |
*-rgt-identity [=>]0.1 | \[ \frac{1}{x + 1} - \frac{-2 + \color{blue}{x}}{x \cdot \left(x + -1\right)}
\] |
remove-double-neg [<=]0.1 | \[ \frac{1}{x + 1} - \frac{-2 + \color{blue}{\left(-\left(-x\right)\right)}}{x \cdot \left(x + -1\right)}
\] |
mul-1-neg [<=]0.1 | \[ \frac{1}{x + 1} - \frac{-2 + \color{blue}{-1 \cdot \left(-x\right)}}{x \cdot \left(x + -1\right)}
\] |
mul-1-neg [=>]0.1 | \[ \frac{1}{x + 1} - \frac{-2 + \color{blue}{\left(-\left(-x\right)\right)}}{x \cdot \left(x + -1\right)}
\] |
remove-double-neg [=>]0.1 | \[ \frac{1}{x + 1} - \frac{-2 + \color{blue}{x}}{x \cdot \left(x + -1\right)}
\] |
Applied egg-rr0.0
if -4.9999999999999997e-12 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < 0.0Initial program 19.3
Simplified19.3
[Start]19.3 | \[ \left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\] |
|---|---|
associate-+l- [=>]19.3 | \[ \color{blue}{\frac{1}{x + 1} - \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
sub-neg [=>]19.3 | \[ \color{blue}{\frac{1}{x + 1} + \left(-\left(\frac{2}{x} - \frac{1}{x - 1}\right)\right)}
\] |
neg-mul-1 [=>]19.3 | \[ \frac{1}{x + 1} + \color{blue}{-1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
metadata-eval [<=]19.3 | \[ \frac{1}{x + 1} + \color{blue}{\left(-1\right)} \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)
\] |
cancel-sign-sub-inv [<=]19.3 | \[ \color{blue}{\frac{1}{x + 1} - 1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
+-commutative [=>]19.3 | \[ \frac{1}{\color{blue}{1 + x}} - 1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)
\] |
*-lft-identity [=>]19.3 | \[ \frac{1}{1 + x} - \color{blue}{\left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
sub-neg [=>]19.3 | \[ \frac{1}{1 + x} - \left(\frac{2}{x} - \frac{1}{\color{blue}{x + \left(-1\right)}}\right)
\] |
metadata-eval [=>]19.3 | \[ \frac{1}{1 + x} - \left(\frac{2}{x} - \frac{1}{x + \color{blue}{-1}}\right)
\] |
Taylor expanded in x around inf 0.6
Applied egg-rr0.1
if 0.0 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) Initial program 1.5
Simplified1.5
[Start]1.5 | \[ \left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\] |
|---|---|
associate-+l- [=>]1.5 | \[ \color{blue}{\frac{1}{x + 1} - \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
sub-neg [=>]1.5 | \[ \color{blue}{\frac{1}{x + 1} + \left(-\left(\frac{2}{x} - \frac{1}{x - 1}\right)\right)}
\] |
neg-mul-1 [=>]1.5 | \[ \frac{1}{x + 1} + \color{blue}{-1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
metadata-eval [<=]1.5 | \[ \frac{1}{x + 1} + \color{blue}{\left(-1\right)} \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)
\] |
cancel-sign-sub-inv [<=]1.5 | \[ \color{blue}{\frac{1}{x + 1} - 1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
+-commutative [=>]1.5 | \[ \frac{1}{\color{blue}{1 + x}} - 1 \cdot \left(\frac{2}{x} - \frac{1}{x - 1}\right)
\] |
*-lft-identity [=>]1.5 | \[ \frac{1}{1 + x} - \color{blue}{\left(\frac{2}{x} - \frac{1}{x - 1}\right)}
\] |
sub-neg [=>]1.5 | \[ \frac{1}{1 + x} - \left(\frac{2}{x} - \frac{1}{\color{blue}{x + \left(-1\right)}}\right)
\] |
metadata-eval [=>]1.5 | \[ \frac{1}{1 + x} - \left(\frac{2}{x} - \frac{1}{x + \color{blue}{-1}}\right)
\] |
Applied egg-rr1.5
Simplified1.5
[Start]1.5 | \[ \frac{1}{1 + x} - \frac{\frac{-2 + \left(2 \cdot x - x\right)}{x}}{1} \cdot \frac{1}{x + -1}
\] |
|---|---|
*-commutative [=>]1.5 | \[ \frac{1}{1 + x} - \color{blue}{\frac{1}{x + -1} \cdot \frac{\frac{-2 + \left(2 \cdot x - x\right)}{x}}{1}}
\] |
/-rgt-identity [=>]1.5 | \[ \frac{1}{1 + x} - \frac{1}{x + -1} \cdot \color{blue}{\frac{-2 + \left(2 \cdot x - x\right)}{x}}
\] |
associate-*r/ [=>]1.5 | \[ \frac{1}{1 + x} - \color{blue}{\frac{\frac{1}{x + -1} \cdot \left(-2 + \left(2 \cdot x - x\right)\right)}{x}}
\] |
*-commutative [=>]1.5 | \[ \frac{1}{1 + x} - \frac{\frac{1}{x + -1} \cdot \left(-2 + \left(\color{blue}{x \cdot 2} - x\right)\right)}{x}
\] |
Applied egg-rr1.5
Simplified1.6
[Start]1.5 | \[ \frac{1}{1 + x} + \left(-\frac{\frac{1}{x + -1} \cdot \left(-2 + \left(x \cdot 2 - x\right)\right)}{x}\right)
\] |
|---|---|
sub-neg [<=]1.5 | \[ \color{blue}{\frac{1}{1 + x} - \frac{\frac{1}{x + -1} \cdot \left(-2 + \left(x \cdot 2 - x\right)\right)}{x}}
\] |
associate-*l/ [<=]1.6 | \[ \frac{1}{1 + x} - \color{blue}{\frac{\frac{1}{x + -1}}{x} \cdot \left(-2 + \left(x \cdot 2 - x\right)\right)}
\] |
+-commutative [=>]1.6 | \[ \frac{1}{\color{blue}{x + 1}} - \frac{\frac{1}{x + -1}}{x} \cdot \left(-2 + \left(x \cdot 2 - x\right)\right)
\] |
associate-/l/ [=>]1.6 | \[ \frac{1}{x + 1} - \color{blue}{\frac{1}{x \cdot \left(x + -1\right)}} \cdot \left(-2 + \left(x \cdot 2 - x\right)\right)
\] |
associate-*l/ [=>]1.6 | \[ \frac{1}{x + 1} - \color{blue}{\frac{1 \cdot \left(-2 + \left(x \cdot 2 - x\right)\right)}{x \cdot \left(x + -1\right)}}
\] |
*-lft-identity [=>]1.6 | \[ \frac{1}{x + 1} - \frac{\color{blue}{-2 + \left(x \cdot 2 - x\right)}}{x \cdot \left(x + -1\right)}
\] |
sub-neg [=>]1.6 | \[ \frac{1}{x + 1} - \frac{-2 + \color{blue}{\left(x \cdot 2 + \left(-x\right)\right)}}{x \cdot \left(x + -1\right)}
\] |
*-commutative [=>]1.6 | \[ \frac{1}{x + 1} - \frac{-2 + \left(\color{blue}{2 \cdot x} + \left(-x\right)\right)}{x \cdot \left(x + -1\right)}
\] |
neg-mul-1 [=>]1.6 | \[ \frac{1}{x + 1} - \frac{-2 + \left(2 \cdot x + \color{blue}{-1 \cdot x}\right)}{x \cdot \left(x + -1\right)}
\] |
distribute-rgt-out [=>]1.6 | \[ \frac{1}{x + 1} - \frac{-2 + \color{blue}{x \cdot \left(2 + -1\right)}}{x \cdot \left(x + -1\right)}
\] |
metadata-eval [=>]1.6 | \[ \frac{1}{x + 1} - \frac{-2 + x \cdot \color{blue}{1}}{x \cdot \left(x + -1\right)}
\] |
*-rgt-identity [=>]1.6 | \[ \frac{1}{x + 1} - \frac{-2 + \color{blue}{x}}{x \cdot \left(x + -1\right)}
\] |
remove-double-neg [<=]1.6 | \[ \frac{1}{x + 1} - \frac{-2 + \color{blue}{\left(-\left(-x\right)\right)}}{x \cdot \left(x + -1\right)}
\] |
mul-1-neg [<=]1.6 | \[ \frac{1}{x + 1} - \frac{-2 + \color{blue}{-1 \cdot \left(-x\right)}}{x \cdot \left(x + -1\right)}
\] |
mul-1-neg [=>]1.6 | \[ \frac{1}{x + 1} - \frac{-2 + \color{blue}{\left(-\left(-x\right)\right)}}{x \cdot \left(x + -1\right)}
\] |
remove-double-neg [=>]1.6 | \[ \frac{1}{x + 1} - \frac{-2 + \color{blue}{x}}{x \cdot \left(x + -1\right)}
\] |
Applied egg-rr0.9
Simplified0.9
[Start]0.9 | \[ \frac{\left(x + -1\right) \cdot \left(-x\right) - \left(-1 - x\right) \cdot \left(-2 + x\right)}{\left(-1 - x\right) \cdot \left(x \cdot \left(x + -1\right)\right)}
\] |
|---|---|
*-commutative [=>]0.9 | \[ \frac{\color{blue}{\left(-x\right) \cdot \left(x + -1\right)} - \left(-1 - x\right) \cdot \left(-2 + x\right)}{\left(-1 - x\right) \cdot \left(x \cdot \left(x + -1\right)\right)}
\] |
mul-1-neg [<=]0.9 | \[ \frac{\color{blue}{\left(-1 \cdot x\right)} \cdot \left(x + -1\right) - \left(-1 - x\right) \cdot \left(-2 + x\right)}{\left(-1 - x\right) \cdot \left(x \cdot \left(x + -1\right)\right)}
\] |
*-commutative [=>]0.9 | \[ \frac{\color{blue}{\left(x \cdot -1\right)} \cdot \left(x + -1\right) - \left(-1 - x\right) \cdot \left(-2 + x\right)}{\left(-1 - x\right) \cdot \left(x \cdot \left(x + -1\right)\right)}
\] |
associate-*l* [=>]0.9 | \[ \frac{\color{blue}{x \cdot \left(-1 \cdot \left(x + -1\right)\right)} - \left(-1 - x\right) \cdot \left(-2 + x\right)}{\left(-1 - x\right) \cdot \left(x \cdot \left(x + -1\right)\right)}
\] |
distribute-lft-in [=>]0.9 | \[ \frac{x \cdot \color{blue}{\left(-1 \cdot x + -1 \cdot -1\right)} - \left(-1 - x\right) \cdot \left(-2 + x\right)}{\left(-1 - x\right) \cdot \left(x \cdot \left(x + -1\right)\right)}
\] |
metadata-eval [=>]0.9 | \[ \frac{x \cdot \left(-1 \cdot x + \color{blue}{1}\right) - \left(-1 - x\right) \cdot \left(-2 + x\right)}{\left(-1 - x\right) \cdot \left(x \cdot \left(x + -1\right)\right)}
\] |
+-commutative [<=]0.9 | \[ \frac{x \cdot \color{blue}{\left(1 + -1 \cdot x\right)} - \left(-1 - x\right) \cdot \left(-2 + x\right)}{\left(-1 - x\right) \cdot \left(x \cdot \left(x + -1\right)\right)}
\] |
mul-1-neg [=>]0.9 | \[ \frac{x \cdot \left(1 + \color{blue}{\left(-x\right)}\right) - \left(-1 - x\right) \cdot \left(-2 + x\right)}{\left(-1 - x\right) \cdot \left(x \cdot \left(x + -1\right)\right)}
\] |
sub-neg [<=]0.9 | \[ \frac{x \cdot \color{blue}{\left(1 - x\right)} - \left(-1 - x\right) \cdot \left(-2 + x\right)}{\left(-1 - x\right) \cdot \left(x \cdot \left(x + -1\right)\right)}
\] |
*-commutative [=>]0.9 | \[ \frac{x \cdot \left(1 - x\right) - \color{blue}{\left(-2 + x\right) \cdot \left(-1 - x\right)}}{\left(-1 - x\right) \cdot \left(x \cdot \left(x + -1\right)\right)}
\] |
+-commutative [=>]0.9 | \[ \frac{x \cdot \left(1 - x\right) - \color{blue}{\left(x + -2\right)} \cdot \left(-1 - x\right)}{\left(-1 - x\right) \cdot \left(x \cdot \left(x + -1\right)\right)}
\] |
*-commutative [=>]0.9 | \[ \frac{x \cdot \left(1 - x\right) - \left(x + -2\right) \cdot \left(-1 - x\right)}{\color{blue}{\left(x \cdot \left(x + -1\right)\right) \cdot \left(-1 - x\right)}}
\] |
associate-*l* [=>]0.9 | \[ \frac{x \cdot \left(1 - x\right) - \left(x + -2\right) \cdot \left(-1 - x\right)}{\color{blue}{x \cdot \left(\left(x + -1\right) \cdot \left(-1 - x\right)\right)}}
\] |
Final simplification0.3
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 3528 |
| Alternative 2 | |
|---|---|
| Error | 0.6 |
| Cost | 2504 |
| Alternative 3 | |
|---|---|
| Error | 0.6 |
| Cost | 2504 |
| Alternative 4 | |
|---|---|
| Error | 0.6 |
| Cost | 2504 |
| Alternative 5 | |
|---|---|
| Error | 0.6 |
| Cost | 2504 |
| Alternative 6 | |
|---|---|
| Error | 0.1 |
| Cost | 1737 |
| Alternative 7 | |
|---|---|
| Error | 0.6 |
| Cost | 713 |
| Alternative 8 | |
|---|---|
| Error | 15.4 |
| Cost | 585 |
| Alternative 9 | |
|---|---|
| Error | 10.6 |
| Cost | 448 |
| Alternative 10 | |
|---|---|
| Error | 30.4 |
| Cost | 192 |
| Alternative 11 | |
|---|---|
| Error | 61.9 |
| Cost | 64 |
herbie shell --seed 2023187
(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))))