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 r44048896 = 6.0;
        double r44048897 = x;
        double r44048898 = 1.0;
        double r44048899 = r44048897 - r44048898;
        double r44048900 = r44048896 * r44048899;
        double r44048901 = r44048897 + r44048898;
        double r44048902 = 4.0;
        double r44048903 = sqrt(r44048897);
        double r44048904 = r44048902 * r44048903;
        double r44048905 = r44048901 + r44048904;
        double r44048906 = r44048900 / r44048905;
        return r44048906;
}

double f(double x) {
        double r44048907 = 1.0;
        double r44048908 = x;
        double r44048909 = sqrt(r44048908);
        double r44048910 = 4.0;
        double r44048911 = 1.0;
        double r44048912 = r44048911 + r44048908;
        double r44048913 = fma(r44048909, r44048910, r44048912);
        double r44048914 = sqrt(r44048913);
        double r44048915 = sqrt(r44048911);
        double r44048916 = r44048909 + r44048915;
        double r44048917 = r44048914 / r44048916;
        double r44048918 = r44048907 / r44048917;
        double r44048919 = r44048909 - r44048915;
        double r44048920 = r44048914 / r44048919;
        double r44048921 = r44048918 / r44048920;
        double r44048922 = 6.0;
        double r44048923 = r44048921 * r44048922;
        return r44048923;
}

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)))))