Average Error: 37.6 → 25.3
Time: 40.9s
Precision: 64
Internal Precision: 4416
\[\frac{0.5}{\sqrt{\left(4 \cdot p\right) \cdot p + r \cdot r} \cdot \sqrt{0.5 \cdot \left(1 + \frac{r}{\sqrt{\left(4 \cdot p\right) \cdot p + r \cdot r}}\right)}}\]
\[\begin{array}{l} \mathbf{if}\;p \le -9.853934825791699 \cdot 10^{-116}:\\ \;\;\;\;\frac{0.5}{\sqrt{\left(1 + \frac{r}{\sqrt{r \cdot r + \left(p \cdot 4\right) \cdot p}}\right) \cdot 0.5} \cdot \left(p \cdot -2\right)}\\ \mathbf{elif}\;p \le 2.2585478044005836 \cdot 10^{-87}:\\ \;\;\;\;\frac{0.5}{\sqrt{1.0} \cdot r}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{\sqrt{2.0} \cdot p + \frac{r}{\sqrt{2.0}} \cdot 0.5}\\ \end{array}\]

Error

Bits error versus p

Bits error versus r

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if p < -9.853934825791699e-116

    1. Initial program 35.3

      \[\frac{0.5}{\sqrt{\left(4 \cdot p\right) \cdot p + r \cdot r} \cdot \sqrt{0.5 \cdot \left(1 + \frac{r}{\sqrt{\left(4 \cdot p\right) \cdot p + r \cdot r}}\right)}}\]
    2. Taylor expanded around -inf 19.5

      \[\leadsto \frac{0.5}{\color{blue}{\left(-2 \cdot p\right)} \cdot \sqrt{0.5 \cdot \left(1 + \frac{r}{\sqrt{\left(4 \cdot p\right) \cdot p + r \cdot r}}\right)}}\]

    if -9.853934825791699e-116 < p < 2.2585478044005836e-87

    1. Initial program 41.0

      \[\frac{0.5}{\sqrt{\left(4 \cdot p\right) \cdot p + r \cdot r} \cdot \sqrt{0.5 \cdot \left(1 + \frac{r}{\sqrt{\left(4 \cdot p\right) \cdot p + r \cdot r}}\right)}}\]
    2. Taylor expanded around 0 36.9

      \[\leadsto \frac{0.5}{\color{blue}{\sqrt{1.0} \cdot r}}\]

    if 2.2585478044005836e-87 < p

    1. Initial program 36.5

      \[\frac{0.5}{\sqrt{\left(4 \cdot p\right) \cdot p + r \cdot r} \cdot \sqrt{0.5 \cdot \left(1 + \frac{r}{\sqrt{\left(4 \cdot p\right) \cdot p + r \cdot r}}\right)}}\]
    2. Using strategy rm
    3. Applied sqrt-unprod36.4

      \[\leadsto \frac{0.5}{\color{blue}{\sqrt{\left(\left(4 \cdot p\right) \cdot p + r \cdot r\right) \cdot \left(0.5 \cdot \left(1 + \frac{r}{\sqrt{\left(4 \cdot p\right) \cdot p + r \cdot r}}\right)\right)}}}\]
    4. Taylor expanded around inf 19.4

      \[\leadsto \frac{0.5}{\color{blue}{0.5 \cdot \frac{r}{\sqrt{2.0}} + p \cdot \sqrt{2.0}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification25.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;p \le -9.853934825791699 \cdot 10^{-116}:\\ \;\;\;\;\frac{0.5}{\sqrt{\left(1 + \frac{r}{\sqrt{r \cdot r + \left(p \cdot 4\right) \cdot p}}\right) \cdot 0.5} \cdot \left(p \cdot -2\right)}\\ \mathbf{elif}\;p \le 2.2585478044005836 \cdot 10^{-87}:\\ \;\;\;\;\frac{0.5}{\sqrt{1.0} \cdot r}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{\sqrt{2.0} \cdot p + \frac{r}{\sqrt{2.0}} \cdot 0.5}\\ \end{array}\]

Runtime

Time bar (total: 40.9s)Debug log

herbie shell --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)' 
(FPCore (p r)
  :name "0.5/(sqrt(4*p*p + r*r) *sqrt(0.5*(1 +r/sqrt(4*p*p + r*r))))"
  (/ 0.5 (* (sqrt (+ (* (* 4 p) p) (* r r))) (sqrt (* 0.5 (+ 1 (/ r (sqrt (+ (* (* 4 p) p) (* r r))))))))))