Average Error: 13.3 → 13.3
Time: 7.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 \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 r392023 = 0.5;
        double r392024 = 1.0;
        double r392025 = x;
        double r392026 = 4.0;
        double r392027 = p;
        double r392028 = r392026 * r392027;
        double r392029 = r392028 * r392027;
        double r392030 = r392025 * r392025;
        double r392031 = r392029 + r392030;
        double r392032 = sqrt(r392031);
        double r392033 = r392025 / r392032;
        double r392034 = r392024 + r392033;
        double r392035 = r392023 * r392034;
        double r392036 = sqrt(r392035);
        return r392036;
}

double f(double p, double x) {
        double r392037 = 0.5;
        double r392038 = 1.0;
        double r392039 = x;
        double r392040 = 4.0;
        double r392041 = p;
        double r392042 = r392040 * r392041;
        double r392043 = r392042 * r392041;
        double r392044 = r392039 * r392039;
        double r392045 = r392043 + r392044;
        double r392046 = sqrt(r392045);
        double r392047 = r392039 / r392046;
        double r392048 = r392038 + r392047;
        double r392049 = exp(r392048);
        double r392050 = sqrt(r392049);
        double r392051 = log(r392050);
        double r392052 = r392051 + r392051;
        double r392053 = r392037 * r392052;
        double r392054 = sqrt(r392053);
        return r392054;
}

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 
(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))))))))