Average Error: 23.6 → 16.5
Time: 33.1s
Precision: 64
Internal Precision: 2624
\[\sqrt{0.5 \cdot \left(1 + \frac{q}{\sqrt{p \cdot p + q \cdot q}}\right)}\]
\[\begin{array}{l} \mathbf{if}\;q \le -9.72744973566335 \cdot 10^{+175}:\\ \;\;\;\;\sqrt{0}\\ \mathbf{if}\;q \le 6.294595312968477 \cdot 10^{+146}:\\ \;\;\;\;\sqrt{0.5 \cdot \log \left(e^{1 + \frac{q}{\sqrt{p \cdot 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.72744973566335e+175

    1. Initial program 55.5

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

      \[\leadsto \sqrt{0.5 \cdot \color{blue}{0}}\]
    3. Applied simplify35.2

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

    if -9.72744973566335e+175 < q < 6.294595312968477e+146

    1. Initial program 15.4

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

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

    if 6.294595312968477e+146 < q

    1. Initial program 43.0

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

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

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

Runtime

Time bar (total: 33.1s)Debug log

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