Average Error: 33.4 → 9.9
Time: 33.0s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.522272609891281 \cdot 10^{+91}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 2.9396032746133623 \cdot 10^{-65}:\\ \;\;\;\;\frac{\sqrt{{b}^{2} - \left(c \cdot a\right) \cdot 4} + \left(-b\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \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.4
Target20.2
Herbie9.9
\[\begin{array}{l} \mathbf{if}\;b \lt 0:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if b < -1.522272609891281e+91

    1. Initial program 42.7

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

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

    if -1.522272609891281e+91 < b < 2.9396032746133623e-65

    1. Initial program 13.3

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

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

    if 2.9396032746133623e-65 < b

    1. Initial program 52.6

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

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

      \[\leadsto \color{blue}{\frac{-c}{b}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.522272609891281 \cdot 10^{+91}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 2.9396032746133623 \cdot 10^{-65}:\\ \;\;\;\;\frac{\sqrt{{b}^{2} - \left(c \cdot a\right) \cdot 4} + \left(-b\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Runtime

Time bar (total: 33.0s)Debug logProfile

herbie shell --seed 2018348 
(FPCore (a b c)
  :name "The quadratic formula (r1)"

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

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