Average Error: 12.9 → 12.9
Time: 13.6s
Precision: 64
\[1.000000000000000006295358232172963997211 \cdot 10^{-150} \lt \left|x\right| \lt 9.999999999999999808355961724373745905731 \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 \log \left(e^{\sqrt[3]{{\left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, {x}^{2}\right)}}\right)}^{3}}}\right)}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\sqrt{0.5 \cdot \log \left(e^{\sqrt[3]{{\left(1 + \frac{x}{\sqrt{\mathsf{fma}\left(4, {p}^{2}, {x}^{2}\right)}}\right)}^{3}}}\right)}
double f(double p, double x) {
        double r233324 = 0.5;
        double r233325 = 1.0;
        double r233326 = x;
        double r233327 = 4.0;
        double r233328 = p;
        double r233329 = r233327 * r233328;
        double r233330 = r233329 * r233328;
        double r233331 = r233326 * r233326;
        double r233332 = r233330 + r233331;
        double r233333 = sqrt(r233332);
        double r233334 = r233326 / r233333;
        double r233335 = r233325 + r233334;
        double r233336 = r233324 * r233335;
        double r233337 = sqrt(r233336);
        return r233337;
}

double f(double p, double x) {
        double r233338 = 0.5;
        double r233339 = 1.0;
        double r233340 = x;
        double r233341 = 4.0;
        double r233342 = p;
        double r233343 = 2.0;
        double r233344 = pow(r233342, r233343);
        double r233345 = pow(r233340, r233343);
        double r233346 = fma(r233341, r233344, r233345);
        double r233347 = sqrt(r233346);
        double r233348 = r233340 / r233347;
        double r233349 = r233339 + r233348;
        double r233350 = 3.0;
        double r233351 = pow(r233349, r233350);
        double r233352 = cbrt(r233351);
        double r233353 = exp(r233352);
        double r233354 = log(r233353);
        double r233355 = r233338 * r233354;
        double r233356 = sqrt(r233355);
        return r233356;
}

Error

Bits error versus p

Bits error versus x

Target

Original12.9
Target12.9
Herbie12.9
\[\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 12.9

    \[\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-log-exp12.9

    \[\leadsto \sqrt{0.5 \cdot \left(1 + \color{blue}{\log \left(e^{\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}\right)}\]
  4. Applied add-log-exp12.9

    \[\leadsto \sqrt{0.5 \cdot \left(\color{blue}{\log \left(e^{1}\right)} + \log \left(e^{\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)\right)}\]
  5. Applied sum-log12.9

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

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

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

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

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

Reproduce

herbie shell --seed 2019351 +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))))))))