Average Error: 13.3 → 13.3
Time: 12.0s
Precision: 64
\[1.00000000000000001 \cdot 10^{-150} \lt \left|x\right| \lt 9.99999999999999981 \cdot 10^{149}\]
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}\]
\[\sqrt{0.5 \cdot e^{\sqrt[3]{{\left(\sqrt[3]{{\left(\sqrt[3]{{\left(\log \left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, x \cdot x\right)}}\right)\right)}^{3}}\right)}^{3}}\right)}^{3}}}}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\sqrt{0.5 \cdot e^{\sqrt[3]{{\left(\sqrt[3]{{\left(\sqrt[3]{{\left(\log \left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, x \cdot x\right)}}\right)\right)}^{3}}\right)}^{3}}\right)}^{3}}}}
double f(double p, double x) {
        double r276196 = 0.5;
        double r276197 = 1.0;
        double r276198 = x;
        double r276199 = 4.0;
        double r276200 = p;
        double r276201 = r276199 * r276200;
        double r276202 = r276201 * r276200;
        double r276203 = r276198 * r276198;
        double r276204 = r276202 + r276203;
        double r276205 = sqrt(r276204);
        double r276206 = r276198 / r276205;
        double r276207 = r276197 + r276206;
        double r276208 = r276196 * r276207;
        double r276209 = sqrt(r276208);
        return r276209;
}

double f(double p, double x) {
        double r276210 = 0.5;
        double r276211 = 1.0;
        double r276212 = x;
        double r276213 = 4.0;
        double r276214 = p;
        double r276215 = 2.0;
        double r276216 = pow(r276214, r276215);
        double r276217 = r276212 * r276212;
        double r276218 = fma(r276213, r276216, r276217);
        double r276219 = sqrt(r276218);
        double r276220 = r276212 / r276219;
        double r276221 = r276211 + r276220;
        double r276222 = log(r276221);
        double r276223 = 3.0;
        double r276224 = pow(r276222, r276223);
        double r276225 = cbrt(r276224);
        double r276226 = pow(r276225, r276223);
        double r276227 = cbrt(r276226);
        double r276228 = pow(r276227, r276223);
        double r276229 = cbrt(r276228);
        double r276230 = exp(r276229);
        double r276231 = r276210 * r276230;
        double r276232 = sqrt(r276231);
        return r276232;
}

Error

Bits error versus p

Bits error versus x

Target

Original13.3
Target13.3
Herbie13.3
\[\sqrt{0.5 + \frac{\mathsf{copysign}\left(0.5, x\right)}{\mathsf{hypot}\left(1, \frac{2 \cdot p}{x}\right)}}\]

Derivation

  1. Initial program 13.3

    \[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}\]
  2. Using strategy rm
  3. Applied add-exp-log13.3

    \[\leadsto \sqrt{0.5 \cdot \color{blue}{e^{\log \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}}}\]
  4. Simplified13.3

    \[\leadsto \sqrt{0.5 \cdot e^{\color{blue}{\log \left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, x \cdot x\right)}}\right)}}}\]
  5. Using strategy rm
  6. Applied add-cbrt-cube13.3

    \[\leadsto \sqrt{0.5 \cdot e^{\color{blue}{\sqrt[3]{\left(\log \left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, x \cdot x\right)}}\right) \cdot \log \left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, x \cdot x\right)}}\right)\right) \cdot \log \left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, x \cdot x\right)}}\right)}}}}\]
  7. Simplified13.3

    \[\leadsto \sqrt{0.5 \cdot e^{\sqrt[3]{\color{blue}{{\left(\log \left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, x \cdot x\right)}}\right)\right)}^{3}}}}}\]
  8. Using strategy rm
  9. Applied add-cbrt-cube13.3

    \[\leadsto \sqrt{0.5 \cdot e^{\sqrt[3]{{\color{blue}{\left(\sqrt[3]{\left(\log \left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, x \cdot x\right)}}\right) \cdot \log \left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, x \cdot x\right)}}\right)\right) \cdot \log \left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, x \cdot x\right)}}\right)}\right)}}^{3}}}}\]
  10. Simplified13.3

    \[\leadsto \sqrt{0.5 \cdot e^{\sqrt[3]{{\left(\sqrt[3]{\color{blue}{{\left(\log \left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, x \cdot x\right)}}\right)\right)}^{3}}}\right)}^{3}}}}\]
  11. Using strategy rm
  12. Applied add-cbrt-cube13.3

    \[\leadsto \sqrt{0.5 \cdot e^{\sqrt[3]{{\left(\sqrt[3]{{\color{blue}{\left(\sqrt[3]{\left(\log \left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, x \cdot x\right)}}\right) \cdot \log \left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, x \cdot x\right)}}\right)\right) \cdot \log \left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, x \cdot x\right)}}\right)}\right)}}^{3}}\right)}^{3}}}}\]
  13. Simplified13.3

    \[\leadsto \sqrt{0.5 \cdot e^{\sqrt[3]{{\left(\sqrt[3]{{\left(\sqrt[3]{\color{blue}{{\left(\log \left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, x \cdot x\right)}}\right)\right)}^{3}}}\right)}^{3}}\right)}^{3}}}}\]
  14. Final simplification13.3

    \[\leadsto \sqrt{0.5 \cdot e^{\sqrt[3]{{\left(\sqrt[3]{{\left(\sqrt[3]{{\left(\log \left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, x \cdot x\right)}}\right)\right)}^{3}}\right)}^{3}}\right)}^{3}}}}\]

Reproduce

herbie shell --seed 2020042 +o rules:numerics
(FPCore (p x)
  :name "Given's Rotation SVD example"
  :precision binary64
  :pre (< 1e-150 (fabs x) 1e+150)

  :herbie-target
  (sqrt (+ 0.5 (/ (copysign 0.5 x) (hypot 1 (/ (* 2 p) x)))))

  (sqrt (* 0.5 (+ 1 (/ x (sqrt (+ (* (* 4 p) p) (* x x))))))))