Average Error: 13.1 → 13.4
Time: 6.0s
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)}\]
\[e^{\log \left(\log \left(e^{\sqrt{0.5 \cdot \left(1 + x \cdot \frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}}\right)\right)}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
e^{\log \left(\log \left(e^{\sqrt{0.5 \cdot \left(1 + x \cdot \frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}}\right)\right)}
double f(double p, double x) {
        double r220180 = 0.5;
        double r220181 = 1.0;
        double r220182 = x;
        double r220183 = 4.0;
        double r220184 = p;
        double r220185 = r220183 * r220184;
        double r220186 = r220185 * r220184;
        double r220187 = r220182 * r220182;
        double r220188 = r220186 + r220187;
        double r220189 = sqrt(r220188);
        double r220190 = r220182 / r220189;
        double r220191 = r220181 + r220190;
        double r220192 = r220180 * r220191;
        double r220193 = sqrt(r220192);
        return r220193;
}

double f(double p, double x) {
        double r220194 = 0.5;
        double r220195 = 1.0;
        double r220196 = x;
        double r220197 = 1.0;
        double r220198 = 4.0;
        double r220199 = p;
        double r220200 = r220198 * r220199;
        double r220201 = r220200 * r220199;
        double r220202 = r220196 * r220196;
        double r220203 = r220201 + r220202;
        double r220204 = sqrt(r220203);
        double r220205 = r220197 / r220204;
        double r220206 = r220196 * r220205;
        double r220207 = r220195 + r220206;
        double r220208 = r220194 * r220207;
        double r220209 = sqrt(r220208);
        double r220210 = exp(r220209);
        double r220211 = log(r220210);
        double r220212 = log(r220211);
        double r220213 = exp(r220212);
        return r220213;
}

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 div-inv13.3

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

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

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

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

Reproduce

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