Average Error: 0.2 → 0.1
Time: 1.2m
Precision: 64
\[\frac{6.0 \cdot \left(x - 1.0\right)}{\left(x + 1.0\right) + 4.0 \cdot \sqrt{x}}\]
\[\frac{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, 1.0 + x\right)}}{\sqrt{x} + \sqrt{1.0}}}}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, 1.0 + x\right)}}{\sqrt{x} - \sqrt{1.0}}} \cdot 6.0\]
\frac{6.0 \cdot \left(x - 1.0\right)}{\left(x + 1.0\right) + 4.0 \cdot \sqrt{x}}
\frac{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, 1.0 + x\right)}}{\sqrt{x} + \sqrt{1.0}}}}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, 1.0 + x\right)}}{\sqrt{x} - \sqrt{1.0}}} \cdot 6.0
double f(double x) {
        double r46517603 = 6.0;
        double r46517604 = x;
        double r46517605 = 1.0;
        double r46517606 = r46517604 - r46517605;
        double r46517607 = r46517603 * r46517606;
        double r46517608 = r46517604 + r46517605;
        double r46517609 = 4.0;
        double r46517610 = sqrt(r46517604);
        double r46517611 = r46517609 * r46517610;
        double r46517612 = r46517608 + r46517611;
        double r46517613 = r46517607 / r46517612;
        return r46517613;
}

double f(double x) {
        double r46517614 = 1.0;
        double r46517615 = x;
        double r46517616 = sqrt(r46517615);
        double r46517617 = 4.0;
        double r46517618 = 1.0;
        double r46517619 = r46517618 + r46517615;
        double r46517620 = fma(r46517616, r46517617, r46517619);
        double r46517621 = sqrt(r46517620);
        double r46517622 = sqrt(r46517618);
        double r46517623 = r46517616 + r46517622;
        double r46517624 = r46517621 / r46517623;
        double r46517625 = r46517614 / r46517624;
        double r46517626 = r46517616 - r46517622;
        double r46517627 = r46517621 / r46517626;
        double r46517628 = r46517625 / r46517627;
        double r46517629 = 6.0;
        double r46517630 = r46517628 * r46517629;
        return r46517630;
}

Error

Bits error versus x

Target

Original0.2
Target0.1
Herbie0.1
\[\frac{6.0}{\frac{\left(x + 1.0\right) + 4.0 \cdot \sqrt{x}}{x - 1.0}}\]

Derivation

  1. Initial program 0.2

    \[\frac{6.0 \cdot \left(x - 1.0\right)}{\left(x + 1.0\right) + 4.0 \cdot \sqrt{x}}\]
  2. Simplified0.1

    \[\leadsto \color{blue}{\frac{6.0}{\frac{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}{x - 1.0}}}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt0.1

    \[\leadsto \frac{6.0}{\frac{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}{x - \color{blue}{\sqrt{1.0} \cdot \sqrt{1.0}}}}\]
  5. Applied add-sqr-sqrt0.3

    \[\leadsto \frac{6.0}{\frac{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}{\color{blue}{\sqrt{x} \cdot \sqrt{x}} - \sqrt{1.0} \cdot \sqrt{1.0}}}\]
  6. Applied difference-of-squares0.3

    \[\leadsto \frac{6.0}{\frac{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}{\color{blue}{\left(\sqrt{x} + \sqrt{1.0}\right) \cdot \left(\sqrt{x} - \sqrt{1.0}\right)}}}\]
  7. Applied add-sqr-sqrt0.1

    \[\leadsto \frac{6.0}{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)} \cdot \sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}}{\left(\sqrt{x} + \sqrt{1.0}\right) \cdot \left(\sqrt{x} - \sqrt{1.0}\right)}}\]
  8. Applied times-frac0.1

    \[\leadsto \frac{6.0}{\color{blue}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} + \sqrt{1.0}} \cdot \frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} - \sqrt{1.0}}}}\]
  9. Applied associate-/r*0.1

    \[\leadsto \color{blue}{\frac{\frac{6.0}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} + \sqrt{1.0}}}}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} - \sqrt{1.0}}}}\]
  10. Using strategy rm
  11. Applied *-un-lft-identity0.1

    \[\leadsto \frac{\frac{6.0}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} + \sqrt{1.0}}}}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} - \sqrt{\color{blue}{1 \cdot 1.0}}}}\]
  12. Applied sqrt-prod0.1

    \[\leadsto \frac{\frac{6.0}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} + \sqrt{1.0}}}}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} - \color{blue}{\sqrt{1} \cdot \sqrt{1.0}}}}\]
  13. Applied *-un-lft-identity0.1

    \[\leadsto \frac{\frac{6.0}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} + \sqrt{1.0}}}}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{\color{blue}{1 \cdot x}} - \sqrt{1} \cdot \sqrt{1.0}}}\]
  14. Applied sqrt-prod0.1

    \[\leadsto \frac{\frac{6.0}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} + \sqrt{1.0}}}}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\color{blue}{\sqrt{1} \cdot \sqrt{x}} - \sqrt{1} \cdot \sqrt{1.0}}}\]
  15. Applied distribute-lft-out--0.1

    \[\leadsto \frac{\frac{6.0}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} + \sqrt{1.0}}}}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\color{blue}{\sqrt{1} \cdot \left(\sqrt{x} - \sqrt{1.0}\right)}}}\]
  16. Applied *-un-lft-identity0.1

    \[\leadsto \frac{\frac{6.0}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} + \sqrt{1.0}}}}{\frac{\sqrt{\color{blue}{1 \cdot \mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}}{\sqrt{1} \cdot \left(\sqrt{x} - \sqrt{1.0}\right)}}\]
  17. Applied sqrt-prod0.1

    \[\leadsto \frac{\frac{6.0}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} + \sqrt{1.0}}}}{\frac{\color{blue}{\sqrt{1} \cdot \sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}}{\sqrt{1} \cdot \left(\sqrt{x} - \sqrt{1.0}\right)}}\]
  18. Applied times-frac0.1

    \[\leadsto \frac{\frac{6.0}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} + \sqrt{1.0}}}}{\color{blue}{\frac{\sqrt{1}}{\sqrt{1}} \cdot \frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} - \sqrt{1.0}}}}\]
  19. Applied div-inv0.1

    \[\leadsto \frac{\color{blue}{6.0 \cdot \frac{1}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} + \sqrt{1.0}}}}}{\frac{\sqrt{1}}{\sqrt{1}} \cdot \frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} - \sqrt{1.0}}}\]
  20. Applied times-frac0.1

    \[\leadsto \color{blue}{\frac{6.0}{\frac{\sqrt{1}}{\sqrt{1}}} \cdot \frac{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} + \sqrt{1.0}}}}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} - \sqrt{1.0}}}}\]
  21. Simplified0.1

    \[\leadsto \color{blue}{6.0} \cdot \frac{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} + \sqrt{1.0}}}}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, x + 1.0\right)}}{\sqrt{x} - \sqrt{1.0}}}\]
  22. Final simplification0.1

    \[\leadsto \frac{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, 1.0 + x\right)}}{\sqrt{x} + \sqrt{1.0}}}}{\frac{\sqrt{\mathsf{fma}\left(\sqrt{x}, 4.0, 1.0 + x\right)}}{\sqrt{x} - \sqrt{1.0}}} \cdot 6.0\]

Reproduce

herbie shell --seed 2019163 +o rules:numerics
(FPCore (x)
  :name "Data.Approximate.Numerics:blog from approximate-0.2.2.1"

  :herbie-target
  (/ 6.0 (/ (+ (+ x 1.0) (* 4.0 (sqrt x))) (- x 1.0)))

  (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))))