Average Error: 12.9 → 12.9
Time: 11.3s
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 e^{\log \left(\frac{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}{\frac{x \cdot x}{\left(4 \cdot p\right) \cdot p + x \cdot x} + 1 \cdot \left(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 e^{\log \left(\frac{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}{\frac{x \cdot x}{\left(4 \cdot p\right) \cdot p + x \cdot x} + 1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}\right)}}
double f(double p, double x) {
        double r333176 = 0.5;
        double r333177 = 1.0;
        double r333178 = x;
        double r333179 = 4.0;
        double r333180 = p;
        double r333181 = r333179 * r333180;
        double r333182 = r333181 * r333180;
        double r333183 = r333178 * r333178;
        double r333184 = r333182 + r333183;
        double r333185 = sqrt(r333184);
        double r333186 = r333178 / r333185;
        double r333187 = r333177 + r333186;
        double r333188 = r333176 * r333187;
        double r333189 = sqrt(r333188);
        return r333189;
}

double f(double p, double x) {
        double r333190 = 0.5;
        double r333191 = 1.0;
        double r333192 = 3.0;
        double r333193 = pow(r333191, r333192);
        double r333194 = x;
        double r333195 = 4.0;
        double r333196 = p;
        double r333197 = r333195 * r333196;
        double r333198 = r333197 * r333196;
        double r333199 = r333194 * r333194;
        double r333200 = r333198 + r333199;
        double r333201 = sqrt(r333200);
        double r333202 = r333194 / r333201;
        double r333203 = pow(r333202, r333192);
        double r333204 = r333193 + r333203;
        double r333205 = r333199 / r333200;
        double r333206 = r333191 - r333202;
        double r333207 = r333191 * r333206;
        double r333208 = r333205 + r333207;
        double r333209 = r333204 / r333208;
        double r333210 = log(r333209);
        double r333211 = exp(r333210);
        double r333212 = r333190 * r333211;
        double r333213 = sqrt(r333212);
        return r333213;
}

Error

Bits error versus p

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}}\]
  7. Using strategy rm
  8. Applied flip3-+12.9

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

    \[\leadsto \sqrt{0.5 \cdot \log \left(e^{\frac{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}{\color{blue}{\frac{x \cdot x}{\left(4 \cdot p\right) \cdot p + x \cdot x} + 1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}}}\right)}\]
  10. Using strategy rm
  11. Applied add-exp-log12.9

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

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

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

Reproduce

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