Average Error: 32.9 → 6.3
Time: 36.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.628278339169478 \cdot 10^{+149}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le 1.5161853332160458 \cdot 10^{-263}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{\sqrt{\left(c \cdot a\right) \cdot -4 + b \cdot b}} \cdot \sqrt{\sqrt{\left(c \cdot a\right) \cdot -4 + b \cdot b}} - b}\\ \mathbf{elif}\;b \le 6.959770719239994 \cdot 10^{+151}:\\ \;\;\;\;\frac{-b}{a \cdot 2} - \frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \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

Original32.9
Target19.9
Herbie6.3
\[\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.628278339169478e+149

    1. Initial program 62.6

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

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

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

    if -3.628278339169478e+149 < b < 1.5161853332160458e-263

    1. Initial program 32.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 flip--32.8

      \[\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/37.3

      \[\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. Simplified19.3

      \[\leadsto \frac{\color{blue}{\left(c \cdot 4\right) \cdot a}}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}\]
    6. Using strategy rm
    7. Applied associate-/r*13.5

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

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

      \[\leadsto \frac{\color{blue}{2 \cdot c}}{\sqrt{-4 \cdot \left(a \cdot c\right) + b \cdot b} - b}\]
    10. Using strategy rm
    11. Applied add-sqr-sqrt8.0

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

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

    if 1.5161853332160458e-263 < b < 6.959770719239994e+151

    1. Initial program 8.1

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

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

    if 6.959770719239994e+151 < b

    1. Initial program 59.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.628278339169478 \cdot 10^{+149}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le 1.5161853332160458 \cdot 10^{-263}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{\sqrt{\left(c \cdot a\right) \cdot -4 + b \cdot b}} \cdot \sqrt{\sqrt{\left(c \cdot a\right) \cdot -4 + b \cdot b}} - b}\\ \mathbf{elif}\;b \le 6.959770719239994 \cdot 10^{+151}:\\ \;\;\;\;\frac{-b}{a \cdot 2} - \frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]

Runtime

Time bar (total: 36.1s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes28.86.35.623.296.7%
herbie shell --seed 2018296 
(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)))