Average Error: 29.4 → 25.3
Time: 12.2s
Precision: 64
Internal Precision: 2368
\[\left(-p\right) + \sqrt{{p}^{2} + q}\]
\[\begin{array}{l} \mathbf{if}\;p \le 9.80074659114093 \cdot 10^{+117}:\\ \;\;\;\;\sqrt{p \cdot p + q} - p\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Error

Bits error versus p

Bits error versus q

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if p < 9.80074659114093e+117

    1. Initial program 21.5

      \[\left(-p\right) + \sqrt{{p}^{2} + q}\]
    2. Initial simplification21.5

      \[\leadsto \sqrt{q + p \cdot p} - p\]

    if 9.80074659114093e+117 < p

    1. Initial program 59.8

      \[\left(-p\right) + \sqrt{{p}^{2} + q}\]
    2. Initial simplification59.8

      \[\leadsto \sqrt{q + p \cdot p} - p\]
    3. Taylor expanded around 0 40.1

      \[\leadsto \color{blue}{0}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification25.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;p \le 9.80074659114093 \cdot 10^{+117}:\\ \;\;\;\;\sqrt{p \cdot p + q} - p\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Runtime

Time bar (total: 12.2s)Debug log

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