Average Error: 13.3 → 13.3
Time: 7.4s
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 \left(\log \left(\sqrt{e^{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\right) + \log \left(\sqrt{e^{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\right)\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 \left(\log \left(\sqrt{e^{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\right) + \log \left(\sqrt{e^{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\right)\right)}
double f(double p, double x) {
        double r370085 = 0.5;
        double r370086 = 1.0;
        double r370087 = x;
        double r370088 = 4.0;
        double r370089 = p;
        double r370090 = r370088 * r370089;
        double r370091 = r370090 * r370089;
        double r370092 = r370087 * r370087;
        double r370093 = r370091 + r370092;
        double r370094 = sqrt(r370093);
        double r370095 = r370087 / r370094;
        double r370096 = r370086 + r370095;
        double r370097 = r370085 * r370096;
        double r370098 = sqrt(r370097);
        return r370098;
}

double f(double p, double x) {
        double r370099 = 0.5;
        double r370100 = 1.0;
        double r370101 = x;
        double r370102 = 4.0;
        double r370103 = p;
        double r370104 = r370102 * r370103;
        double r370105 = r370104 * r370103;
        double r370106 = r370101 * r370101;
        double r370107 = r370105 + r370106;
        double r370108 = sqrt(r370107);
        double r370109 = r370101 / r370108;
        double r370110 = r370100 + r370109;
        double r370111 = exp(r370110);
        double r370112 = sqrt(r370111);
        double r370113 = log(r370112);
        double r370114 = r370113 + r370113;
        double r370115 = r370099 * r370114;
        double r370116 = sqrt(r370115);
        return r370116;
}

Error

Bits error versus p

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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-log-exp13.3

    \[\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-exp13.3

    \[\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-log13.3

    \[\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. Simplified13.3

    \[\leadsto \sqrt{0.5 \cdot \log \color{blue}{\left(e^{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}}\]
  7. Using strategy rm
  8. Applied add-sqr-sqrt13.3

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

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

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

Reproduce

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