Average Error: 13.3 → 13.3
Time: 33.1s
Precision: 64
\[10^{-150} \lt \left|x\right| \lt 10^{+150}\]
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}\]
\[\sqrt{e^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left(\left(\frac{1}{\frac{\sqrt{\mathsf{fma}\left(p, \left(4 \cdot p\right), \left(x \cdot x\right)\right)}}{x}}\right), 0.5, 0.5\right)\right)} \cdot \sqrt[3]{\log \left(\mathsf{fma}\left(\left(\frac{1}{\frac{\sqrt{\mathsf{fma}\left(p, \left(4 \cdot p\right), \left(x \cdot x\right)\right)}}{x}}\right), 0.5, 0.5\right)\right)}\right) \cdot \sqrt[3]{\log \left(\sqrt[3]{\mathsf{fma}\left(\left(\frac{1}{\frac{\sqrt{\mathsf{fma}\left(p, \left(4 \cdot p\right), \left(x \cdot x\right)\right)}}{x}}\right), 0.5, 0.5\right) \cdot \left(\mathsf{fma}\left(\left(\frac{1}{\frac{\sqrt{\mathsf{fma}\left(p, \left(4 \cdot p\right), \left(x \cdot x\right)\right)}}{x}}\right), 0.5, 0.5\right) \cdot \mathsf{fma}\left(\left(\frac{1}{\frac{\sqrt{\mathsf{fma}\left(p, \left(4 \cdot p\right), \left(x \cdot x\right)\right)}}{x}}\right), 0.5, 0.5\right)\right)}\right)}}}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\sqrt{e^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left(\left(\frac{1}{\frac{\sqrt{\mathsf{fma}\left(p, \left(4 \cdot p\right), \left(x \cdot x\right)\right)}}{x}}\right), 0.5, 0.5\right)\right)} \cdot \sqrt[3]{\log \left(\mathsf{fma}\left(\left(\frac{1}{\frac{\sqrt{\mathsf{fma}\left(p, \left(4 \cdot p\right), \left(x \cdot x\right)\right)}}{x}}\right), 0.5, 0.5\right)\right)}\right) \cdot \sqrt[3]{\log \left(\sqrt[3]{\mathsf{fma}\left(\left(\frac{1}{\frac{\sqrt{\mathsf{fma}\left(p, \left(4 \cdot p\right), \left(x \cdot x\right)\right)}}{x}}\right), 0.5, 0.5\right) \cdot \left(\mathsf{fma}\left(\left(\frac{1}{\frac{\sqrt{\mathsf{fma}\left(p, \left(4 \cdot p\right), \left(x \cdot x\right)\right)}}{x}}\right), 0.5, 0.5\right) \cdot \mathsf{fma}\left(\left(\frac{1}{\frac{\sqrt{\mathsf{fma}\left(p, \left(4 \cdot p\right), \left(x \cdot x\right)\right)}}{x}}\right), 0.5, 0.5\right)\right)}\right)}}}
double f(double p, double x) {
        double r65104335 = 0.5;
        double r65104336 = 1.0;
        double r65104337 = x;
        double r65104338 = 4.0;
        double r65104339 = p;
        double r65104340 = r65104338 * r65104339;
        double r65104341 = r65104340 * r65104339;
        double r65104342 = r65104337 * r65104337;
        double r65104343 = r65104341 + r65104342;
        double r65104344 = sqrt(r65104343);
        double r65104345 = r65104337 / r65104344;
        double r65104346 = r65104336 + r65104345;
        double r65104347 = r65104335 * r65104346;
        double r65104348 = sqrt(r65104347);
        return r65104348;
}

double f(double p, double x) {
        double r65104349 = 1.0;
        double r65104350 = p;
        double r65104351 = 4.0;
        double r65104352 = r65104351 * r65104350;
        double r65104353 = x;
        double r65104354 = r65104353 * r65104353;
        double r65104355 = fma(r65104350, r65104352, r65104354);
        double r65104356 = sqrt(r65104355);
        double r65104357 = r65104356 / r65104353;
        double r65104358 = r65104349 / r65104357;
        double r65104359 = 0.5;
        double r65104360 = fma(r65104358, r65104359, r65104359);
        double r65104361 = log(r65104360);
        double r65104362 = cbrt(r65104361);
        double r65104363 = r65104362 * r65104362;
        double r65104364 = r65104360 * r65104360;
        double r65104365 = r65104360 * r65104364;
        double r65104366 = cbrt(r65104365);
        double r65104367 = log(r65104366);
        double r65104368 = cbrt(r65104367);
        double r65104369 = r65104363 * r65104368;
        double r65104370 = exp(r65104369);
        double r65104371 = sqrt(r65104370);
        return r65104371;
}

Error

Bits error versus p

Bits error versus x

Target

Original13.3
Target13.3
Herbie13.3
\[\sqrt{\frac{1}{2} + \frac{\mathsf{copysign}\left(\frac{1}{2}, x\right)}{\mathsf{hypot}\left(1, \left(\frac{2 \cdot p}{x}\right)\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. Simplified13.3

    \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(\left(\frac{x}{\sqrt{\mathsf{fma}\left(p, \left(4 \cdot p\right), \left(x \cdot x\right)\right)}}\right), 0.5, 0.5\right)}}\]
  3. Using strategy rm
  4. Applied *-un-lft-identity13.3

    \[\leadsto \sqrt{\mathsf{fma}\left(\left(\frac{\color{blue}{1 \cdot x}}{\sqrt{\mathsf{fma}\left(p, \left(4 \cdot p\right), \left(x \cdot x\right)\right)}}\right), 0.5, 0.5\right)}\]
  5. Applied associate-/l*13.3

    \[\leadsto \sqrt{\mathsf{fma}\left(\color{blue}{\left(\frac{1}{\frac{\sqrt{\mathsf{fma}\left(p, \left(4 \cdot p\right), \left(x \cdot x\right)\right)}}{x}}\right)}, 0.5, 0.5\right)}\]
  6. Using strategy rm
  7. Applied add-exp-log13.3

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

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

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

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

Reproduce

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

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

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