Average Error: 33.0 → 12.7
Time: 37.5s
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 -2.116092086722358 \cdot 10^{+92}:\\ \;\;\;\;\frac{-2 \cdot \frac{a \cdot c}{b}}{a \cdot 2}\\ \mathbf{elif}\;b \le -1.1138846873684963 \cdot 10^{-130}:\\ \;\;\;\;\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 2.170378666312612 \cdot 10^{+50}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a} \cdot \frac{1}{2}\\ \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.0
Target20.5
Herbie12.7
\[\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 < -2.116092086722358e+92

    1. Initial program 57.6

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

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

    if -2.116092086722358e+92 < b < -1.1138846873684963e-130

    1. Initial program 39.2

      \[\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--39.3

      \[\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.2

      \[\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.2

      \[\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 -1.1138846873684963e-130 < b < 2.170378666312612e+50

    1. Initial program 12.0

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity12.0

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

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

    if 2.170378666312612e+50 < b

    1. Initial program 35.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.116092086722358 \cdot 10^{+92}:\\ \;\;\;\;\frac{-2 \cdot \frac{a \cdot c}{b}}{a \cdot 2}\\ \mathbf{elif}\;b \le -1.1138846873684963 \cdot 10^{-130}:\\ \;\;\;\;\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 2.170378666312612 \cdot 10^{+50}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a} \cdot \frac{1}{2}\\ \mathbf{else}:\\ \;\;\;\;-\frac{b}{a}\\ \end{array}\]

Runtime

Time bar (total: 37.5s)Debug logProfile

herbie shell --seed 2018219 
(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)))