Average Error: 13.1 → 13.4
Time: 5.4s
Precision: binary64
\[10^{-150} < \left|x\right| \land \left|x\right| < 10^{+150}\]
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}\]
\[\log \left(e^{\sqrt{\left(1 + x \cdot \frac{1}{\sqrt{4 \cdot \left(p \cdot p\right) + x \cdot x}}\right) \cdot 0.5}}\right)\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\log \left(e^{\sqrt{\left(1 + x \cdot \frac{1}{\sqrt{4 \cdot \left(p \cdot p\right) + x \cdot x}}\right) \cdot 0.5}}\right)
double code(double p, double x) {
	return ((double) sqrt(((double) (0.5 * ((double) (1.0 + (x / ((double) sqrt(((double) (((double) (((double) (4.0 * p)) * p)) + ((double) (x * x)))))))))))));
}
double code(double p, double x) {
	return ((double) log(((double) exp(((double) sqrt(((double) (((double) (1.0 + ((double) (x * (1.0 / ((double) sqrt(((double) (((double) (4.0 * ((double) (p * p)))) + ((double) (x * x))))))))))) * 0.5))))))));
}

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 Error: 13.1 bits

    \[\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-expError: 13.1 bits

    \[\leadsto \color{blue}{\log \left(e^{\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}}\right)}\]
  4. SimplifiedError: 13.1 bits

    \[\leadsto \log \color{blue}{\left(e^{\sqrt{\left(1 + \frac{x}{\sqrt{4 \cdot \left(p \cdot p\right) + x \cdot x}}\right) \cdot 0.5}}\right)}\]
  5. Using strategy rm
  6. Applied div-invError: 13.4 bits

    \[\leadsto \log \left(e^{\sqrt{\left(1 + \color{blue}{x \cdot \frac{1}{\sqrt{4 \cdot \left(p \cdot p\right) + x \cdot x}}}\right) \cdot 0.5}}\right)\]
  7. Final simplificationError: 13.4 bits

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

Reproduce

herbie shell --seed 2020200 
(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.0 (/ (* 2.0 p) x)))))

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