Average Error: 33.3 → 12.0
Time: 58.1s
Precision: 64
Internal Precision: 3392
\[\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 -3.4580500412981637 \cdot 10^{+124}:\\ \;\;\;\;\frac{-2 \cdot \frac{a \cdot c}{b}}{a \cdot 2}\\ \mathbf{elif}\;b \le -9.164732542528427 \cdot 10^{-135}:\\ \;\;\;\;\frac{4 \cdot \left(a \cdot c\right)}{\left(a \cdot 2\right) \cdot \left(\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} + \left(-b\right)\right)}\\ \mathbf{elif}\;b \le 7.244591904232477 \cdot 10^{+152}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 2}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{b}{a}\\ \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.3
Target21.0
Herbie12.0
\[\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 4 regimes
  2. if b < -3.4580500412981637e+124

    1. Initial program 59.8

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

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

    if -3.4580500412981637e+124 < b < -9.164732542528427e-135

    1. Initial program 39.9

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied flip--40.0

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} \cdot \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}{2 \cdot a}\]
    4. Applied associate-/l/42.7

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

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

    if -9.164732542528427e-135 < b < 7.244591904232477e+152

    1. Initial program 10.4

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied clear-num10.5

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

    if 7.244591904232477e+152 < b

    1. Initial program 60.3

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

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

      \[\leadsto \color{blue}{\frac{-b}{a}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification12.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.4580500412981637 \cdot 10^{+124}:\\ \;\;\;\;\frac{-2 \cdot \frac{a \cdot c}{b}}{a \cdot 2}\\ \mathbf{elif}\;b \le -9.164732542528427 \cdot 10^{-135}:\\ \;\;\;\;\frac{4 \cdot \left(a \cdot c\right)}{\left(a \cdot 2\right) \cdot \left(\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} + \left(-b\right)\right)}\\ \mathbf{elif}\;b \le 7.244591904232477 \cdot 10^{+152}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 2}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{b}{a}\\ \end{array}\]

Runtime

Time bar (total: 58.1s)Debug logProfile

herbie shell --seed 2018221 +o rules:numerics
(FPCore (a b c)
  :name "quadm (p42, negative)"

  :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)))