Average Error: 22.8 → 10.9
Time: 41.7s
Precision: 64
Internal Precision: 3392
\[\sqrt{0.5 \cdot \left(1 + \frac{q}{\sqrt{p + q \cdot q}}\right)}\]
\[\begin{array}{l} \mathbf{if}\;q \le -9.74180062808602 \cdot 10^{+175}:\\ \;\;\;\;\sqrt{0}\\ \mathbf{if}\;q \le 3.7899226995403642 \cdot 10^{+124}:\\ \;\;\;\;\sqrt{0.5 \cdot \left(1 + \left(q \cdot \left(\sqrt[3]{\frac{1}{\sqrt{p + q \cdot q}}} \cdot \sqrt[3]{\frac{1}{\sqrt{p + q \cdot q}}}\right)\right) \cdot \sqrt[3]{\frac{1}{\sqrt{p + q \cdot q}}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5 + 0.5}\\ \end{array}\]

Error

Bits error versus q

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 < -9.74180062808602e+175

    1. Initial program 61.5

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

      \[\leadsto \sqrt{0.5 \cdot \color{blue}{0}}\]
    3. Applied simplify43.9

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

    if -9.74180062808602e+175 < q < 3.7899226995403642e+124

    1. Initial program 10.4

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

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

      \[\leadsto \sqrt{0.5 \cdot \left(1 + q \cdot \color{blue}{\left(\left(\sqrt[3]{\frac{1}{\sqrt{p + q \cdot q}}} \cdot \sqrt[3]{\frac{1}{\sqrt{p + q \cdot q}}}\right) \cdot \sqrt[3]{\frac{1}{\sqrt{p + q \cdot q}}}\right)}\right)}\]
    6. Applied associate-*r*10.5

      \[\leadsto \sqrt{0.5 \cdot \left(1 + \color{blue}{\left(q \cdot \left(\sqrt[3]{\frac{1}{\sqrt{p + q \cdot q}}} \cdot \sqrt[3]{\frac{1}{\sqrt{p + q \cdot q}}}\right)\right) \cdot \sqrt[3]{\frac{1}{\sqrt{p + q \cdot q}}}}\right)}\]

    if 3.7899226995403642e+124 < q

    1. Initial program 43.1

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

      \[\leadsto \sqrt{0.5 \cdot \left(1 + \frac{q}{\color{blue}{q}}\right)}\]
    3. Applied simplify0.3

      \[\leadsto \color{blue}{\sqrt{0.5 + 0.5}}\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 41.7s)Debug log

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