Average Error: 14.8 → 0.1
Time: 21.8s
Precision: 64
\[\frac{1}{1 + 2 \cdot x} - \frac{1 - x}{1 + x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0003108335940490056:\\ \;\;\;\;\left(\frac{1}{1 + x \cdot 2} - \frac{1}{1 + x}\right) + \frac{x}{1 + x}\\ \mathbf{elif}\;x \le 0.0002329754277795241:\\ \;\;\;\;14 \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) + \left(x \cdot x\right) \cdot \left(2 - x \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{\frac{\frac{1}{1 + x \cdot 2}}{1 + x \cdot 2}}{1 + x \cdot 2}} - \frac{1 - x}{1 + x}\\ \end{array}\]
\frac{1}{1 + 2 \cdot x} - \frac{1 - x}{1 + x}
\begin{array}{l}
\mathbf{if}\;x \le -0.0003108335940490056:\\
\;\;\;\;\left(\frac{1}{1 + x \cdot 2} - \frac{1}{1 + x}\right) + \frac{x}{1 + x}\\

\mathbf{elif}\;x \le 0.0002329754277795241:\\
\;\;\;\;14 \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) + \left(x \cdot x\right) \cdot \left(2 - x \cdot 6\right)\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{\frac{\frac{1}{1 + x \cdot 2}}{1 + x \cdot 2}}{1 + x \cdot 2}} - \frac{1 - x}{1 + x}\\

\end{array}
double f(double x) {
        double r36929281 = 1.0;
        double r36929282 = 2.0;
        double r36929283 = x;
        double r36929284 = r36929282 * r36929283;
        double r36929285 = r36929281 + r36929284;
        double r36929286 = r36929281 / r36929285;
        double r36929287 = r36929281 - r36929283;
        double r36929288 = r36929281 + r36929283;
        double r36929289 = r36929287 / r36929288;
        double r36929290 = r36929286 - r36929289;
        return r36929290;
}

double f(double x) {
        double r36929291 = x;
        double r36929292 = -0.0003108335940490056;
        bool r36929293 = r36929291 <= r36929292;
        double r36929294 = 1.0;
        double r36929295 = 2.0;
        double r36929296 = r36929291 * r36929295;
        double r36929297 = r36929294 + r36929296;
        double r36929298 = r36929294 / r36929297;
        double r36929299 = r36929294 + r36929291;
        double r36929300 = r36929294 / r36929299;
        double r36929301 = r36929298 - r36929300;
        double r36929302 = r36929291 / r36929299;
        double r36929303 = r36929301 + r36929302;
        double r36929304 = 0.0002329754277795241;
        bool r36929305 = r36929291 <= r36929304;
        double r36929306 = 14.0;
        double r36929307 = r36929291 * r36929291;
        double r36929308 = r36929307 * r36929307;
        double r36929309 = r36929306 * r36929308;
        double r36929310 = 6.0;
        double r36929311 = r36929291 * r36929310;
        double r36929312 = r36929295 - r36929311;
        double r36929313 = r36929307 * r36929312;
        double r36929314 = r36929309 + r36929313;
        double r36929315 = r36929298 / r36929297;
        double r36929316 = r36929315 / r36929297;
        double r36929317 = cbrt(r36929316);
        double r36929318 = r36929294 - r36929291;
        double r36929319 = r36929318 / r36929299;
        double r36929320 = r36929317 - r36929319;
        double r36929321 = r36929305 ? r36929314 : r36929320;
        double r36929322 = r36929293 ? r36929303 : r36929321;
        return r36929322;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if x < -0.0003108335940490056

    1. Initial program 0.1

      \[\frac{1}{1 + 2 \cdot x} - \frac{1 - x}{1 + x}\]
    2. Using strategy rm
    3. Applied div-sub0.2

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

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

    if -0.0003108335940490056 < x < 0.0002329754277795241

    1. Initial program 30.3

      \[\frac{1}{1 + 2 \cdot x} - \frac{1 - x}{1 + x}\]
    2. Taylor expanded around 0 0.1

      \[\leadsto \color{blue}{\left(2 \cdot {x}^{2} + 14 \cdot {x}^{4}\right) - 6 \cdot {x}^{3}}\]
    3. Simplified0.1

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

    if 0.0002329754277795241 < x

    1. Initial program 0.2

      \[\frac{1}{1 + 2 \cdot x} - \frac{1 - x}{1 + x}\]
    2. Using strategy rm
    3. Applied add-cbrt-cube0.2

      \[\leadsto \frac{1}{\color{blue}{\sqrt[3]{\left(\left(1 + 2 \cdot x\right) \cdot \left(1 + 2 \cdot x\right)\right) \cdot \left(1 + 2 \cdot x\right)}}} - \frac{1 - x}{1 + x}\]
    4. Applied add-cbrt-cube0.2

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

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

      \[\leadsto \sqrt[3]{\color{blue}{\frac{\frac{\frac{1}{x \cdot 2 + 1}}{x \cdot 2 + 1}}{x \cdot 2 + 1}}} - \frac{1 - x}{1 + x}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.0003108335940490056:\\ \;\;\;\;\left(\frac{1}{1 + x \cdot 2} - \frac{1}{1 + x}\right) + \frac{x}{1 + x}\\ \mathbf{elif}\;x \le 0.0002329754277795241:\\ \;\;\;\;14 \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) + \left(x \cdot x\right) \cdot \left(2 - x \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{\frac{\frac{1}{1 + x \cdot 2}}{1 + x \cdot 2}}{1 + x \cdot 2}} - \frac{1 - x}{1 + x}\\ \end{array}\]

Reproduce

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