Average Error: 32.6 → 29.9
Time: 1.8m
Precision: 64
Internal Precision: 3392
\[\sqrt{0.5 + \frac{q - r}{2 \cdot \sqrt{p + {\left(q - r\right)}^{2}}}}\]
\[\begin{array}{l} \mathbf{if}\;q - r \le -7.516080057550844 \cdot 10^{+165}:\\ \;\;\;\;\sqrt{0.5 + \frac{q - r}{2 \cdot \left(r - q\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(0.5 + \frac{q}{2 \cdot \sqrt{p + {\left(q - r\right)}^{2}}}\right) - \frac{r}{2 \cdot \left(\left|\sqrt[3]{\left(q - r\right) \cdot \left(q - r\right) + p}\right| \cdot \sqrt{\sqrt[3]{p + {\left(q - r\right)}^{2}}}\right)}}\\ \end{array}\]

Error

Bits error versus q

Bits error versus r

Bits error versus p

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (- q r) < -7.516080057550844e+165

    1. Initial program 61.4

      \[\sqrt{0.5 + \frac{q - r}{2 \cdot \sqrt{p + {\left(q - r\right)}^{2}}}}\]
    2. Taylor expanded around 0 43.5

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

    if -7.516080057550844e+165 < (- q r)

    1. Initial program 27.4

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

      \[\leadsto \sqrt{0.5 + \color{blue}{\left(\frac{q}{2 \cdot \sqrt{p + {\left(q - r\right)}^{2}}} - \frac{r}{2 \cdot \sqrt{p + {\left(q - r\right)}^{2}}}\right)}}\]
    4. Applied associate-+r-27.4

      \[\leadsto \sqrt{\color{blue}{\left(0.5 + \frac{q}{2 \cdot \sqrt{p + {\left(q - r\right)}^{2}}}\right) - \frac{r}{2 \cdot \sqrt{p + {\left(q - r\right)}^{2}}}}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt27.4

      \[\leadsto \sqrt{\left(0.5 + \frac{q}{2 \cdot \sqrt{p + {\left(q - r\right)}^{2}}}\right) - \frac{r}{2 \cdot \sqrt{\color{blue}{\left(\sqrt[3]{p + {\left(q - r\right)}^{2}} \cdot \sqrt[3]{p + {\left(q - r\right)}^{2}}\right) \cdot \sqrt[3]{p + {\left(q - r\right)}^{2}}}}}}\]
    7. Applied sqrt-prod27.4

      \[\leadsto \sqrt{\left(0.5 + \frac{q}{2 \cdot \sqrt{p + {\left(q - r\right)}^{2}}}\right) - \frac{r}{2 \cdot \color{blue}{\left(\sqrt{\sqrt[3]{p + {\left(q - r\right)}^{2}} \cdot \sqrt[3]{p + {\left(q - r\right)}^{2}}} \cdot \sqrt{\sqrt[3]{p + {\left(q - r\right)}^{2}}}\right)}}}\]
    8. Applied simplify27.4

      \[\leadsto \sqrt{\left(0.5 + \frac{q}{2 \cdot \sqrt{p + {\left(q - r\right)}^{2}}}\right) - \frac{r}{2 \cdot \left(\color{blue}{\left|\sqrt[3]{\left(q - r\right) \cdot \left(q - r\right) + p}\right|} \cdot \sqrt{\sqrt[3]{p + {\left(q - r\right)}^{2}}}\right)}}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 1.8m)Debug log

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