Average Error: 36.0 → 22.1
Time: 46.6s
Precision: 64
Internal Precision: 4416
$\frac{p}{\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 -1.5562482193320763 \cdot 10^{+146}:\\ \;\;\;\;\frac{p}{\sqrt{2.0} \cdot \left(-p\right)}\\ \mathbf{elif}\;p \le 5.319959856538636 \cdot 10^{+134}:\\ \;\;\;\;\frac{p}{\sqrt{\left(\left(\frac{r}{\sqrt{\sqrt{r \cdot r + p \cdot \left(4 \cdot p\right)}} \cdot \sqrt{\sqrt{r \cdot r + p \cdot \left(4 \cdot p\right)}}} + 1\right) \cdot 0.5\right) \cdot \left(r \cdot r + p \cdot \left(4 \cdot p\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{p}{\left(2 \cdot p\right) \cdot \sqrt{\left(\frac{r}{\sqrt{r \cdot r + p \cdot \left(4 \cdot p\right)}} + 1\right) \cdot 0.5}}\\ \end{array}$

# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 3 regimes
2. ## if p < -1.5562482193320763e+146

1. Initial program 59.8

$\frac{p}{\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-unprod59.8

$\leadsto \frac{p}{\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 8.6

$\leadsto \frac{p}{\color{blue}{-1 \cdot \left(p \cdot \sqrt{2.0}\right)}}$
5. Simplified8.6

$\leadsto \frac{p}{\color{blue}{\left(-p\right) \cdot \sqrt{2.0}}}$

## if -1.5562482193320763e+146 < p < 5.319959856538636e+134

1. Initial program 27.3

$\frac{p}{\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-unprod27.1

$\leadsto \frac{p}{\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. Using strategy rm

$\leadsto \frac{p}{\sqrt{\left(\left(4 \cdot p\right) \cdot p + r \cdot r\right) \cdot \left(0.5 \cdot \left(1 + \frac{r}{\color{blue}{\sqrt{\sqrt{\left(4 \cdot p\right) \cdot p + r \cdot r}} \cdot \sqrt{\sqrt{\left(4 \cdot p\right) \cdot p + r \cdot r}}}}\right)\right)}}$

## if 5.319959856538636e+134 < p

1. Initial program 57.4

$\frac{p}{\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 9.8

$\leadsto \frac{p}{\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)}}$
3. Recombined 3 regimes into one program.
4. Final simplification22.1

$\leadsto \begin{array}{l} \mathbf{if}\;p \le -1.5562482193320763 \cdot 10^{+146}:\\ \;\;\;\;\frac{p}{\sqrt{2.0} \cdot \left(-p\right)}\\ \mathbf{elif}\;p \le 5.319959856538636 \cdot 10^{+134}:\\ \;\;\;\;\frac{p}{\sqrt{\left(\left(\frac{r}{\sqrt{\sqrt{r \cdot r + p \cdot \left(4 \cdot p\right)}} \cdot \sqrt{\sqrt{r \cdot r + p \cdot \left(4 \cdot p\right)}}} + 1\right) \cdot 0.5\right) \cdot \left(r \cdot r + p \cdot \left(4 \cdot p\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{p}{\left(2 \cdot p\right) \cdot \sqrt{\left(\frac{r}{\sqrt{r \cdot r + p \cdot \left(4 \cdot p\right)}} + 1\right) \cdot 0.5}}\\ \end{array}$

# Runtime

Time bar (total: 46.6s)Debug log

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