Average Error: 13.4 → 13.4
Time: 9.6s
Precision: 64
\[1.00000000000000001 \cdot 10^{-150} \lt \left|x\right| \lt 9.99999999999999981 \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^{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 \log \left(e^{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}
double f(double p, double x) {
        double r328201 = 0.5;
        double r328202 = 1.0;
        double r328203 = x;
        double r328204 = 4.0;
        double r328205 = p;
        double r328206 = r328204 * r328205;
        double r328207 = r328206 * r328205;
        double r328208 = r328203 * r328203;
        double r328209 = r328207 + r328208;
        double r328210 = sqrt(r328209);
        double r328211 = r328203 / r328210;
        double r328212 = r328202 + r328211;
        double r328213 = r328201 * r328212;
        double r328214 = sqrt(r328213);
        return r328214;
}

double f(double p, double x) {
        double r328215 = 0.5;
        double r328216 = 1.0;
        double r328217 = x;
        double r328218 = 4.0;
        double r328219 = p;
        double r328220 = r328218 * r328219;
        double r328221 = r328220 * r328219;
        double r328222 = r328217 * r328217;
        double r328223 = r328221 + r328222;
        double r328224 = sqrt(r328223);
        double r328225 = r328217 / r328224;
        double r328226 = r328216 + r328225;
        double r328227 = exp(r328226);
        double r328228 = log(r328227);
        double r328229 = r328215 * r328228;
        double r328230 = sqrt(r328229);
        return r328230;
}

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.4
Target13.4
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.4

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

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

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

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

    \[\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. Final simplification13.4

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

Reproduce

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