Average Error: 33.2 → 10.4
Time: 42.4s
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.2624163142142334 \cdot 10^{+27}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le -2.014594234406352 \cdot 10^{-62}:\\ \;\;\;\;\frac{\frac{\frac{1}{2}}{a}}{\sqrt{b \cdot b + c \cdot \left(-4 \cdot a\right)} - b} \cdot \frac{a \cdot c}{\frac{1}{4}}\\ \mathbf{elif}\;b \le -1.1320615158913861 \cdot 10^{-146}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le 2.8358752990862995 \cdot 10^{+119}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \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.2
Target20.5
Herbie10.4
\[\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.2624163142142334e+27 or -2.014594234406352e-62 < b < -1.1320615158913861e-146

    1. Initial program 51.7

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

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

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

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

    if -2.2624163142142334e+27 < b < -2.014594234406352e-62

    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 associate-*r*39.9

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(2 \cdot a\right) \cdot \frac{1}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}\]
    8. Applied associate-/r*39.9

      \[\leadsto \color{blue}{\frac{\frac{1}{2 \cdot a}}{\frac{1}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}\]
    9. Using strategy rm
    10. Applied flip--40.0

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

      \[\leadsto \frac{\frac{1}{2 \cdot a}}{\color{blue}{\frac{1}{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}\]
    12. Applied *-un-lft-identity40.0

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

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

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

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

    if -1.1320615158913861e-146 < b < 2.8358752990862995e+119

    1. Initial program 11.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 associate-*r*11.4

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

    if 2.8358752990862995e+119 < b

    1. Initial program 49.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.2624163142142334 \cdot 10^{+27}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le -2.014594234406352 \cdot 10^{-62}:\\ \;\;\;\;\frac{\frac{\frac{1}{2}}{a}}{\sqrt{b \cdot b + c \cdot \left(-4 \cdot a\right)} - b} \cdot \frac{a \cdot c}{\frac{1}{4}}\\ \mathbf{elif}\;b \le -1.1320615158913861 \cdot 10^{-146}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le 2.8358752990862995 \cdot 10^{+119}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]

Runtime

Time bar (total: 42.4s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes33.210.45.727.583.1%
herbie shell --seed 2018352 
(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)))