Average Error: 13.1 → 13.4
Time: 17.9s
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 \frac{\left(\frac{1}{\left(4 \cdot p\right) \cdot p + x \cdot x} \cdot \left(x \cdot x\right)\right) \cdot \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}} + \left(1 \cdot 1\right) \cdot 1}{e^{\log \left(x \cdot x\right) - \log \left(\left(4 \cdot p\right) \cdot p + x \cdot x\right)} + 1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\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 \frac{\left(\frac{1}{\left(4 \cdot p\right) \cdot p + x \cdot x} \cdot \left(x \cdot x\right)\right) \cdot \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}} + \left(1 \cdot 1\right) \cdot 1}{e^{\log \left(x \cdot x\right) - \log \left(\left(4 \cdot p\right) \cdot p + x \cdot x\right)} + 1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}}
double f(double p, double x) {
        double r9001536 = 0.5;
        double r9001537 = 1.0;
        double r9001538 = x;
        double r9001539 = 4.0;
        double r9001540 = p;
        double r9001541 = r9001539 * r9001540;
        double r9001542 = r9001541 * r9001540;
        double r9001543 = r9001538 * r9001538;
        double r9001544 = r9001542 + r9001543;
        double r9001545 = sqrt(r9001544);
        double r9001546 = r9001538 / r9001545;
        double r9001547 = r9001537 + r9001546;
        double r9001548 = r9001536 * r9001547;
        double r9001549 = sqrt(r9001548);
        return r9001549;
}

double f(double p, double x) {
        double r9001550 = 0.5;
        double r9001551 = 1.0;
        double r9001552 = 4.0;
        double r9001553 = p;
        double r9001554 = r9001552 * r9001553;
        double r9001555 = r9001554 * r9001553;
        double r9001556 = x;
        double r9001557 = r9001556 * r9001556;
        double r9001558 = r9001555 + r9001557;
        double r9001559 = r9001551 / r9001558;
        double r9001560 = r9001559 * r9001557;
        double r9001561 = sqrt(r9001558);
        double r9001562 = r9001556 / r9001561;
        double r9001563 = r9001560 * r9001562;
        double r9001564 = 1.0;
        double r9001565 = r9001564 * r9001564;
        double r9001566 = r9001565 * r9001564;
        double r9001567 = r9001563 + r9001566;
        double r9001568 = log(r9001557);
        double r9001569 = log(r9001558);
        double r9001570 = r9001568 - r9001569;
        double r9001571 = exp(r9001570);
        double r9001572 = r9001564 - r9001562;
        double r9001573 = r9001564 * r9001572;
        double r9001574 = r9001571 + r9001573;
        double r9001575 = r9001567 / r9001574;
        double r9001576 = r9001550 * r9001575;
        double r9001577 = sqrt(r9001576);
        return r9001577;
}

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.1
Target13.1
Herbie13.4
\[\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.1

    \[\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 flip3-+13.1

    \[\leadsto \sqrt{0.5 \cdot \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)}}}\]
  4. Simplified13.1

    \[\leadsto \sqrt{0.5 \cdot \frac{\color{blue}{1 \cdot \left(1 \cdot 1\right) + \frac{x \cdot x}{\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 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)}}\]
  5. Simplified13.1

    \[\leadsto \sqrt{0.5 \cdot \frac{1 \cdot \left(1 \cdot 1\right) + \frac{x \cdot x}{\left(4 \cdot p\right) \cdot p + x \cdot x} \cdot \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}{\color{blue}{\left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) \cdot 1 + \frac{x \cdot x}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\]
  6. Using strategy rm
  7. Applied div-inv13.3

    \[\leadsto \sqrt{0.5 \cdot \frac{1 \cdot \left(1 \cdot 1\right) + \color{blue}{\left(\left(x \cdot x\right) \cdot \frac{1}{\left(4 \cdot p\right) \cdot p + x \cdot x}\right)} \cdot \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}{\left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) \cdot 1 + \frac{x \cdot x}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\]
  8. Using strategy rm
  9. Applied add-exp-log14.5

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

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

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

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

Reproduce

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

  :herbie-target
  (sqrt (+ 0.5 (/ (copysign 0.5 x) (hypot 1.0 (/ (* 2.0 p) x)))))

  (sqrt (* 0.5 (+ 1.0 (/ x (sqrt (+ (* (* 4.0 p) p) (* x x))))))))