Average Error: 0.1 → 0.0
Time: 4.9s
Precision: 64
$\frac{1}{x + 2} \cdot \left(x - 2\right)$
$1 \cdot \frac{x - 2}{x + 2}$
\frac{1}{x + 2} \cdot \left(x - 2\right)
1 \cdot \frac{x - 2}{x + 2}
double f(double x) {
double r24178 = 1.0;
double r24179 = x;
double r24180 = 2.0;
double r24181 = r24179 + r24180;
double r24182 = r24178 / r24181;
double r24183 = r24179 - r24180;
double r24184 = r24182 * r24183;
return r24184;
}


double f(double x) {
double r24185 = 1.0;
double r24186 = x;
double r24187 = 2.0;
double r24188 = r24186 - r24187;
double r24189 = r24186 + r24187;
double r24190 = r24188 / r24189;
double r24191 = r24185 * r24190;
return r24191;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 0.1

$\frac{1}{x + 2} \cdot \left(x - 2\right)$
2. Using strategy rm
3. Applied div-inv0.1

$\leadsto \color{blue}{\left(1 \cdot \frac{1}{x + 2}\right)} \cdot \left(x - 2\right)$
4. Applied associate-*l*0.1

$\leadsto \color{blue}{1 \cdot \left(\frac{1}{x + 2} \cdot \left(x - 2\right)\right)}$
5. Simplified0.0

$\leadsto 1 \cdot \color{blue}{\frac{x - 2}{x + 2}}$
6. Final simplification0.0

$\leadsto 1 \cdot \frac{x - 2}{x + 2}$

# Reproduce

herbie shell --seed 1
(FPCore (x)
:name "1/(x+2)(x-2)"
:precision binary64
(* (/ 1 (+ x 2)) (- x 2)))