Average Error: 29.5 → 18.9
Time: 1.9m
Precision: 64
Internal Precision: 2624
$\sqrt{0.5 + \frac{0.5 \cdot \left(q - r\right)}{\sqrt{p \cdot p + \left(q - r\right) \cdot \left(q - r\right)}}}$
$\begin{array}{l} \mathbf{if}\;q - r \le -1.1406838422287146 \cdot 10^{+244}:\\ \;\;\;\;\sqrt{0.5 + \frac{0.5 \cdot \left(q - r\right)}{r - q}}\\ \mathbf{if}\;q - r \le 1.040861142415406 \cdot 10^{+152}:\\ \;\;\;\;\sqrt{0.5 + \left(0.5 \cdot \left(q - r\right)\right) \cdot \frac{1}{\sqrt{p \cdot p + \left(q - r\right) \cdot \left(q - r\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1.0}\\ \end{array}$

# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 3 regimes
2. ## if (- q r) < -1.1406838422287146e+244

1. Initial program 57.9

$\sqrt{0.5 + \frac{0.5 \cdot \left(q - r\right)}{\sqrt{p \cdot p + \left(q - r\right) \cdot \left(q - r\right)}}}$
2. Taylor expanded around 0 34.0

$\leadsto \sqrt{0.5 + \frac{0.5 \cdot \left(q - r\right)}{\color{blue}{r - q}}}$

## if -1.1406838422287146e+244 < (- q r) < 1.040861142415406e+152

1. Initial program 20.4

$\sqrt{0.5 + \frac{0.5 \cdot \left(q - r\right)}{\sqrt{p \cdot p + \left(q - r\right) \cdot \left(q - r\right)}}}$
2. Using strategy rm
3. Applied div-inv20.7

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

## if 1.040861142415406e+152 < (- q r)

1. Initial program 45.1

$\sqrt{0.5 + \frac{0.5 \cdot \left(q - r\right)}{\sqrt{p \cdot p + \left(q - r\right) \cdot \left(q - r\right)}}}$
2. Taylor expanded around inf 6.3

$\leadsto \sqrt{\color{blue}{1.0}}$
3. Recombined 3 regimes into one program.

# Runtime

Time bar (total: 1.9m)Debug log

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