Average Error: 29.5 → 19.2
Time: 36.9s
Precision: 64
Internal Precision: 2624
\[\sqrt{0.5 \cdot \left(1 + \frac{q - r}{\sqrt{\left(4 \cdot p\right) \cdot p + \left(q - r\right) \cdot \left(q - r\right)}}\right)}\]
\[\begin{array}{l} \mathbf{if}\;q - r \le -3.008062495574494 \cdot 10^{+242}:\\ \;\;\;\;0\\ \mathbf{elif}\;q - r \le 1.040861142415406 \cdot 10^{+152}:\\ \;\;\;\;\log \left(e^{\sqrt{0.5 + \frac{\left(q - r\right) \cdot 0.5}{\sqrt{\sqrt{\left(q - r\right) \cdot \left(q - r\right) + p \cdot \left(p \cdot 4\right)}} \cdot \sqrt{\sqrt{\left(q - r\right) \cdot \left(q - r\right) + p \cdot \left(p \cdot 4\right)}}}}}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1.0}\\ \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 3 regimes
  2. if (- q r) < -3.008062495574494e+242

    1. Initial program 57.9

      \[\sqrt{0.5 \cdot \left(1 + \frac{q - r}{\sqrt{\left(4 \cdot p\right) \cdot p + \left(q - r\right) \cdot \left(q - r\right)}}\right)}\]
    2. Initial simplification57.9

      \[\leadsto \sqrt{\frac{0.5 \cdot \left(q - r\right)}{\sqrt{\left(q - r\right) \cdot \left(q - r\right) + p \cdot \left(p \cdot 4\right)}} + 0.5}\]
    3. Taylor expanded around -inf 34.1

      \[\leadsto \color{blue}{0}\]

    if -3.008062495574494e+242 < (- q r) < 1.040861142415406e+152

    1. Initial program 20.3

      \[\sqrt{0.5 \cdot \left(1 + \frac{q - r}{\sqrt{\left(4 \cdot p\right) \cdot p + \left(q - r\right) \cdot \left(q - r\right)}}\right)}\]
    2. Initial simplification20.3

      \[\leadsto \sqrt{\frac{0.5 \cdot \left(q - r\right)}{\sqrt{\left(q - r\right) \cdot \left(q - r\right) + p \cdot \left(p \cdot 4\right)}} + 0.5}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt21.1

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

      \[\leadsto \color{blue}{\log \left(e^{\sqrt{\frac{0.5 \cdot \left(q - r\right)}{\sqrt{\sqrt{\left(q - r\right) \cdot \left(q - r\right) + p \cdot \left(p \cdot 4\right)}} \cdot \sqrt{\sqrt{\left(q - r\right) \cdot \left(q - r\right) + p \cdot \left(p \cdot 4\right)}}} + 0.5}}\right)}\]

    if 1.040861142415406e+152 < (- q r)

    1. Initial program 45.1

      \[\sqrt{0.5 \cdot \left(1 + \frac{q - r}{\sqrt{\left(4 \cdot p\right) \cdot p + \left(q - r\right) \cdot \left(q - r\right)}}\right)}\]
    2. Initial simplification45.1

      \[\leadsto \sqrt{\frac{0.5 \cdot \left(q - r\right)}{\sqrt{\left(q - r\right) \cdot \left(q - r\right) + p \cdot \left(p \cdot 4\right)}} + 0.5}\]
    3. Taylor expanded around inf 6.3

      \[\leadsto \sqrt{\color{blue}{1.0}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification19.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;q - r \le -3.008062495574494 \cdot 10^{+242}:\\ \;\;\;\;0\\ \mathbf{elif}\;q - r \le 1.040861142415406 \cdot 10^{+152}:\\ \;\;\;\;\log \left(e^{\sqrt{0.5 + \frac{\left(q - r\right) \cdot 0.5}{\sqrt{\sqrt{\left(q - r\right) \cdot \left(q - r\right) + p \cdot \left(p \cdot 4\right)}} \cdot \sqrt{\sqrt{\left(q - r\right) \cdot \left(q - r\right) + p \cdot \left(p \cdot 4\right)}}}}}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1.0}\\ \end{array}\]

Runtime

Time bar (total: 36.9s)Debug log

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