Average Error: 9.4 → 10.0
Time: 13.4s
Precision: binary64
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \leq -1.3430294122385343 \cdot 10^{+154} \lor \neg \left(x \leq 1.691942371348407 \cdot 10^{+134}\right):\\ \;\;\;\;\frac{\left(\frac{1}{x + 1} - \frac{2}{x}\right) \cdot \left(\frac{1}{x + 1} - \frac{2}{x}\right) - \frac{\frac{1}{x - 1}}{x - 1}}{\left(\frac{1}{x + 1} - \frac{2}{x}\right) - \frac{1}{x - 1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt[3]{x \cdot x - 1} \cdot \left(x - \left(x + 1\right) \cdot 2\right)\right) \cdot \sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}} + \sqrt[3]{x + 1} \cdot \left(\left(\sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}} \cdot \sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}\right) \cdot \sqrt[3]{x \cdot \left(x + 1\right)}\right)}{\left(\sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}} \cdot \sqrt[3]{x + 1}\right) \cdot \left(\sqrt[3]{x - 1} \cdot \left(x \cdot \left(x + 1\right)\right)\right)}\\ \end{array}\]
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \leq -1.3430294122385343 \cdot 10^{+154} \lor \neg \left(x \leq 1.691942371348407 \cdot 10^{+134}\right):\\
\;\;\;\;\frac{\left(\frac{1}{x + 1} - \frac{2}{x}\right) \cdot \left(\frac{1}{x + 1} - \frac{2}{x}\right) - \frac{\frac{1}{x - 1}}{x - 1}}{\left(\frac{1}{x + 1} - \frac{2}{x}\right) - \frac{1}{x - 1}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(\sqrt[3]{x \cdot x - 1} \cdot \left(x - \left(x + 1\right) \cdot 2\right)\right) \cdot \sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}} + \sqrt[3]{x + 1} \cdot \left(\left(\sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}} \cdot \sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}\right) \cdot \sqrt[3]{x \cdot \left(x + 1\right)}\right)}{\left(\sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}} \cdot \sqrt[3]{x + 1}\right) \cdot \left(\sqrt[3]{x - 1} \cdot \left(x \cdot \left(x + 1\right)\right)\right)}\\

\end{array}
(FPCore (x)
 :precision binary64
 (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
(FPCore (x)
 :precision binary64
 (if (or (<= x -1.3430294122385343e+154) (not (<= x 1.691942371348407e+134)))
   (/
    (-
     (* (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)))
     (/ (/ 1.0 (- x 1.0)) (- x 1.0)))
    (- (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
   (/
    (+
     (*
      (* (cbrt (- (* x x) 1.0)) (- x (* (+ x 1.0) 2.0)))
      (cbrt (pow (cbrt (- x 1.0)) 2.0)))
     (*
      (cbrt (+ x 1.0))
      (*
       (*
        (cbrt (/ (* x (+ x 1.0)) (pow (cbrt (- x 1.0)) 2.0)))
        (cbrt (/ (* x (+ x 1.0)) (pow (cbrt (- x 1.0)) 2.0))))
       (cbrt (* x (+ x 1.0))))))
    (*
     (* (cbrt (pow (cbrt (- x 1.0)) 2.0)) (cbrt (+ x 1.0)))
     (* (cbrt (- x 1.0)) (* x (+ x 1.0)))))))
double code(double x) {
	return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
double code(double x) {
	double tmp;
	if ((x <= -1.3430294122385343e+154) || !(x <= 1.691942371348407e+134)) {
		tmp = ((((1.0 / (x + 1.0)) - (2.0 / x)) * ((1.0 / (x + 1.0)) - (2.0 / x))) - ((1.0 / (x - 1.0)) / (x - 1.0))) / (((1.0 / (x + 1.0)) - (2.0 / x)) - (1.0 / (x - 1.0)));
	} else {
		tmp = (((cbrt((x * x) - 1.0) * (x - ((x + 1.0) * 2.0))) * cbrt(pow(cbrt(x - 1.0), 2.0))) + (cbrt(x + 1.0) * ((cbrt((x * (x + 1.0)) / pow(cbrt(x - 1.0), 2.0)) * cbrt((x * (x + 1.0)) / pow(cbrt(x - 1.0), 2.0))) * cbrt(x * (x + 1.0))))) / ((cbrt(pow(cbrt(x - 1.0), 2.0)) * cbrt(x + 1.0)) * (cbrt(x - 1.0) * (x * (x + 1.0))));
	}
	return tmp;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original9.4
Target0.3
Herbie10.0
\[\frac{2}{x \cdot \left(x \cdot x - 1\right)}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -1.343029412238534e154 or 1.6919423713484069e134 < x

    1. Initial program 0.0

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
    2. Using strategy rm
    3. Applied flip-+_binary640

      \[\leadsto \color{blue}{\frac{\left(\frac{1}{x + 1} - \frac{2}{x}\right) \cdot \left(\frac{1}{x + 1} - \frac{2}{x}\right) - \frac{1}{x - 1} \cdot \frac{1}{x - 1}}{\left(\frac{1}{x + 1} - \frac{2}{x}\right) - \frac{1}{x - 1}}}\]
    4. Simplified1.1

      \[\leadsto \frac{\color{blue}{\left(\frac{1}{1 + x} - \frac{2}{x}\right) \cdot \left(\frac{1}{1 + x} - \frac{2}{x}\right) - \frac{\frac{1}{x - 1}}{x - 1}}}{\left(\frac{1}{x + 1} - \frac{2}{x}\right) - \frac{1}{x - 1}}\]
    5. Simplified1.1

      \[\leadsto \frac{\left(\frac{1}{1 + x} - \frac{2}{x}\right) \cdot \left(\frac{1}{1 + x} - \frac{2}{x}\right) - \frac{\frac{1}{x - 1}}{x - 1}}{\color{blue}{\left(\frac{1}{1 + x} - \frac{2}{x}\right) - \frac{1}{x - 1}}}\]

    if -1.343029412238534e154 < x < 1.6919423713484069e134

    1. Initial program 12.8

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt_binary6417.0

      \[\leadsto \left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{\color{blue}{\left(\sqrt[3]{x - 1} \cdot \sqrt[3]{x - 1}\right) \cdot \sqrt[3]{x - 1}}}\]
    4. Applied associate-/r*_binary6417.3

      \[\leadsto \left(\frac{1}{x + 1} - \frac{2}{x}\right) + \color{blue}{\frac{\frac{1}{\sqrt[3]{x - 1} \cdot \sqrt[3]{x - 1}}}{\sqrt[3]{x - 1}}}\]
    5. Using strategy rm
    6. Applied frac-sub_binary6417.3

      \[\leadsto \color{blue}{\frac{1 \cdot x - \left(x + 1\right) \cdot 2}{\left(x + 1\right) \cdot x}} + \frac{\frac{1}{\sqrt[3]{x - 1} \cdot \sqrt[3]{x - 1}}}{\sqrt[3]{x - 1}}\]
    7. Applied frac-add_binary6416.0

      \[\leadsto \color{blue}{\frac{\left(1 \cdot x - \left(x + 1\right) \cdot 2\right) \cdot \sqrt[3]{x - 1} + \left(\left(x + 1\right) \cdot x\right) \cdot \frac{1}{\sqrt[3]{x - 1} \cdot \sqrt[3]{x - 1}}}{\left(\left(x + 1\right) \cdot x\right) \cdot \sqrt[3]{x - 1}}}\]
    8. Simplified16.1

      \[\leadsto \frac{\color{blue}{\sqrt[3]{x - 1} \cdot \left(x - \left(1 + x\right) \cdot 2\right) + \frac{x \cdot \left(1 + x\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}}{\left(\left(x + 1\right) \cdot x\right) \cdot \sqrt[3]{x - 1}}\]
    9. Simplified16.1

      \[\leadsto \frac{\sqrt[3]{x - 1} \cdot \left(x - \left(1 + x\right) \cdot 2\right) + \frac{x \cdot \left(1 + x\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}{\color{blue}{\sqrt[3]{x - 1} \cdot \left(x \cdot \left(1 + x\right)\right)}}\]
    10. Using strategy rm
    11. Applied add-cube-cbrt_binary6416.1

      \[\leadsto \frac{\sqrt[3]{x - 1} \cdot \left(x - \left(1 + x\right) \cdot 2\right) + \color{blue}{\left(\sqrt[3]{\frac{x \cdot \left(1 + x\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}} \cdot \sqrt[3]{\frac{x \cdot \left(1 + x\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}\right) \cdot \sqrt[3]{\frac{x \cdot \left(1 + x\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}}}{\sqrt[3]{x - 1} \cdot \left(x \cdot \left(1 + x\right)\right)}\]
    12. Simplified16.1

      \[\leadsto \frac{\sqrt[3]{x - 1} \cdot \left(x - \left(1 + x\right) \cdot 2\right) + \color{blue}{\left(\sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}} \cdot \sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}\right)} \cdot \sqrt[3]{\frac{x \cdot \left(1 + x\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}}{\sqrt[3]{x - 1} \cdot \left(x \cdot \left(1 + x\right)\right)}\]
    13. Simplified16.1

      \[\leadsto \frac{\sqrt[3]{x - 1} \cdot \left(x - \left(1 + x\right) \cdot 2\right) + \left(\sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}} \cdot \sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}\right) \cdot \color{blue}{\sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}}}{\sqrt[3]{x - 1} \cdot \left(x \cdot \left(1 + x\right)\right)}\]
    14. Using strategy rm
    15. Applied cbrt-div_binary6416.3

      \[\leadsto \frac{\sqrt[3]{x - 1} \cdot \left(x - \left(1 + x\right) \cdot 2\right) + \left(\sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}} \cdot \sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}\right) \cdot \color{blue}{\frac{\sqrt[3]{x \cdot \left(x + 1\right)}}{\sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}}}}}{\sqrt[3]{x - 1} \cdot \left(x \cdot \left(1 + x\right)\right)}\]
    16. Applied associate-*r/_binary6416.2

      \[\leadsto \frac{\sqrt[3]{x - 1} \cdot \left(x - \left(1 + x\right) \cdot 2\right) + \color{blue}{\frac{\left(\sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}} \cdot \sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}\right) \cdot \sqrt[3]{x \cdot \left(x + 1\right)}}{\sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}}}}}{\sqrt[3]{x - 1} \cdot \left(x \cdot \left(1 + x\right)\right)}\]
    17. Applied flip--_binary6416.2

      \[\leadsto \frac{\sqrt[3]{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}}} \cdot \left(x - \left(1 + x\right) \cdot 2\right) + \frac{\left(\sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}} \cdot \sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}\right) \cdot \sqrt[3]{x \cdot \left(x + 1\right)}}{\sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}}}}{\sqrt[3]{x - 1} \cdot \left(x \cdot \left(1 + x\right)\right)}\]
    18. Applied cbrt-div_binary6416.0

      \[\leadsto \frac{\color{blue}{\frac{\sqrt[3]{x \cdot x - 1 \cdot 1}}{\sqrt[3]{x + 1}}} \cdot \left(x - \left(1 + x\right) \cdot 2\right) + \frac{\left(\sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}} \cdot \sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}\right) \cdot \sqrt[3]{x \cdot \left(x + 1\right)}}{\sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}}}}{\sqrt[3]{x - 1} \cdot \left(x \cdot \left(1 + x\right)\right)}\]
    19. Applied associate-*l/_binary6415.9

      \[\leadsto \frac{\color{blue}{\frac{\sqrt[3]{x \cdot x - 1 \cdot 1} \cdot \left(x - \left(1 + x\right) \cdot 2\right)}{\sqrt[3]{x + 1}}} + \frac{\left(\sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}} \cdot \sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}\right) \cdot \sqrt[3]{x \cdot \left(x + 1\right)}}{\sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}}}}{\sqrt[3]{x - 1} \cdot \left(x \cdot \left(1 + x\right)\right)}\]
    20. Applied frac-add_binary6415.9

      \[\leadsto \frac{\color{blue}{\frac{\left(\sqrt[3]{x \cdot x - 1 \cdot 1} \cdot \left(x - \left(1 + x\right) \cdot 2\right)\right) \cdot \sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}} + \sqrt[3]{x + 1} \cdot \left(\left(\sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}} \cdot \sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}\right) \cdot \sqrt[3]{x \cdot \left(x + 1\right)}\right)}{\sqrt[3]{x + 1} \cdot \sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}}}}}{\sqrt[3]{x - 1} \cdot \left(x \cdot \left(1 + x\right)\right)}\]
    21. Applied associate-/l/_binary6413.1

      \[\leadsto \color{blue}{\frac{\left(\sqrt[3]{x \cdot x - 1 \cdot 1} \cdot \left(x - \left(1 + x\right) \cdot 2\right)\right) \cdot \sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}} + \sqrt[3]{x + 1} \cdot \left(\left(\sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}} \cdot \sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}\right) \cdot \sqrt[3]{x \cdot \left(x + 1\right)}\right)}{\left(\sqrt[3]{x - 1} \cdot \left(x \cdot \left(1 + x\right)\right)\right) \cdot \left(\sqrt[3]{x + 1} \cdot \sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}}\right)}}\]
    22. Simplified13.1

      \[\leadsto \frac{\left(\sqrt[3]{x \cdot x - 1 \cdot 1} \cdot \left(x - \left(1 + x\right) \cdot 2\right)\right) \cdot \sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}} + \sqrt[3]{x + 1} \cdot \left(\left(\sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}} \cdot \sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}\right) \cdot \sqrt[3]{x \cdot \left(x + 1\right)}\right)}{\color{blue}{\left(\sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}} \cdot \sqrt[3]{x + 1}\right) \cdot \left(\sqrt[3]{x - 1} \cdot \left(x \cdot \left(x + 1\right)\right)\right)}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification10.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.3430294122385343 \cdot 10^{+154} \lor \neg \left(x \leq 1.691942371348407 \cdot 10^{+134}\right):\\ \;\;\;\;\frac{\left(\frac{1}{x + 1} - \frac{2}{x}\right) \cdot \left(\frac{1}{x + 1} - \frac{2}{x}\right) - \frac{\frac{1}{x - 1}}{x - 1}}{\left(\frac{1}{x + 1} - \frac{2}{x}\right) - \frac{1}{x - 1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt[3]{x \cdot x - 1} \cdot \left(x - \left(x + 1\right) \cdot 2\right)\right) \cdot \sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}} + \sqrt[3]{x + 1} \cdot \left(\left(\sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}} \cdot \sqrt[3]{\frac{x \cdot \left(x + 1\right)}{{\left(\sqrt[3]{x - 1}\right)}^{2}}}\right) \cdot \sqrt[3]{x \cdot \left(x + 1\right)}\right)}{\left(\sqrt[3]{{\left(\sqrt[3]{x - 1}\right)}^{2}} \cdot \sqrt[3]{x + 1}\right) \cdot \left(\sqrt[3]{x - 1} \cdot \left(x \cdot \left(x + 1\right)\right)\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2020268 
(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))))