Average Error: 33.9 → 9.9
Time: 34.5s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -2.410267969009899 \cdot 10^{-98}:\\ \;\;\;\;-\frac{c}{b}\\ \mathbf{elif}\;b \le 4.8539323749735836 \cdot 10^{+132}:\\ \;\;\;\;\frac{-b}{2 \cdot a} - \frac{\sqrt{{b}^{2} - \left(a \cdot c\right) \cdot 4}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{2 \cdot a} - \left(\frac{1}{2} \cdot \frac{b}{a} - \frac{c}{b}\right)\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original33.9
Target21.0
Herbie9.9
\[\begin{array}{l} \mathbf{if}\;b \lt 0:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if b < -2.410267969009899e-98

    1. Initial program 52.1

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification52.1

      \[\leadsto \frac{\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    3. Taylor expanded around -inf 10.0

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    4. Simplified10.0

      \[\leadsto \color{blue}{\frac{-c}{b}}\]

    if -2.410267969009899e-98 < b < 4.8539323749735836e+132

    1. Initial program 11.9

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification11.9

      \[\leadsto \frac{\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    3. Taylor expanded around -inf 11.9

      \[\leadsto \frac{\left(-b\right) - \sqrt{\color{blue}{{b}^{2} - 4 \cdot \left(a \cdot c\right)}}}{2 \cdot a}\]
    4. Using strategy rm
    5. Applied div-sub11.9

      \[\leadsto \color{blue}{\frac{-b}{2 \cdot a} - \frac{\sqrt{{b}^{2} - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\]

    if 4.8539323749735836e+132 < b

    1. Initial program 53.0

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification53.0

      \[\leadsto \frac{\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    3. Taylor expanded around -inf 53.0

      \[\leadsto \frac{\left(-b\right) - \sqrt{\color{blue}{{b}^{2} - 4 \cdot \left(a \cdot c\right)}}}{2 \cdot a}\]
    4. Using strategy rm
    5. Applied div-sub53.0

      \[\leadsto \color{blue}{\frac{-b}{2 \cdot a} - \frac{\sqrt{{b}^{2} - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\]
    6. Taylor expanded around inf 2.3

      \[\leadsto \frac{-b}{2 \cdot a} - \color{blue}{\left(\frac{1}{2} \cdot \frac{b}{a} - \frac{c}{b}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.410267969009899 \cdot 10^{-98}:\\ \;\;\;\;-\frac{c}{b}\\ \mathbf{elif}\;b \le 4.8539323749735836 \cdot 10^{+132}:\\ \;\;\;\;\frac{-b}{2 \cdot a} - \frac{\sqrt{{b}^{2} - \left(a \cdot c\right) \cdot 4}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{2 \cdot a} - \left(\frac{1}{2} \cdot \frac{b}{a} - \frac{c}{b}\right)\\ \end{array}\]

Runtime

Time bar (total: 34.5s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes34.29.95.628.685.1%
herbie shell --seed 2018354 
(FPCore (a b c)
  :name "The quadratic formula (r2)"

  :herbie-target
  (if (< b 0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))

  (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))