Average Error: 12.9 → 12.9
Time: 13.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{\frac{1}{2} \cdot \frac{\log \left(e^{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}\right)}{1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) + \frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\sqrt{\frac{1}{2} \cdot \frac{\log \left(e^{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}\right)}{1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) + \frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}
double f(double p, double x) {
        double r186167 = 0.5;
        double r186168 = 1.0;
        double r186169 = x;
        double r186170 = 4.0;
        double r186171 = p;
        double r186172 = r186170 * r186171;
        double r186173 = r186172 * r186171;
        double r186174 = r186169 * r186169;
        double r186175 = r186173 + r186174;
        double r186176 = sqrt(r186175);
        double r186177 = r186169 / r186176;
        double r186178 = r186168 + r186177;
        double r186179 = r186167 * r186178;
        double r186180 = sqrt(r186179);
        return r186180;
}

double f(double p, double x) {
        double r186181 = 1.0;
        double r186182 = 2.0;
        double r186183 = r186181 / r186182;
        double r186184 = 3.0;
        double r186185 = pow(r186181, r186184);
        double r186186 = x;
        double r186187 = 4.0;
        double r186188 = p;
        double r186189 = r186187 * r186188;
        double r186190 = r186189 * r186188;
        double r186191 = r186186 * r186186;
        double r186192 = r186190 + r186191;
        double r186193 = sqrt(r186192);
        double r186194 = r186186 / r186193;
        double r186195 = pow(r186194, r186184);
        double r186196 = r186185 + r186195;
        double r186197 = exp(r186196);
        double r186198 = log(r186197);
        double r186199 = r186181 - r186194;
        double r186200 = r186181 * r186199;
        double r186201 = 2.0;
        double r186202 = pow(r186186, r186201);
        double r186203 = r186202 / r186192;
        double r186204 = r186200 + r186203;
        double r186205 = r186198 / r186204;
        double r186206 = r186183 * r186205;
        double r186207 = sqrt(r186206);
        return r186207;
}

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. Simplified12.9

    \[\leadsto \color{blue}{\sqrt{\frac{1}{2} \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}}\]
  3. Using strategy rm
  4. Applied flip3-+12.9

    \[\leadsto \sqrt{\frac{1}{2} \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)}}}\]
  5. Simplified12.9

    \[\leadsto \sqrt{\frac{1}{2} \cdot \frac{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}{\color{blue}{1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) + \frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\]
  6. Using strategy rm
  7. Applied add-log-exp12.9

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

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

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

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

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

Reproduce

herbie shell --seed 2019303 
(FPCore (p x)
  :name "Given's Rotation SVD example"
  :precision binary64
  :pre (< 1.00000000000000001e-150 (fabs x) 9.99999999999999981e149)

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