Average Error: 33.7 → 9.5
Time: 30.6s
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.7781936441701785 \cdot 10^{+42}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le -5.824809921465728 \cdot 10^{-67}:\\ \;\;\;\;\frac{4 \cdot \left(c \cdot a\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) + \sqrt{-4 \cdot \left(c \cdot a\right) + b \cdot b}\right)}\\ \mathbf{elif}\;b \le -1.1583924904629825 \cdot 10^{-132}:\\ \;\;\;\;\frac{\left(c \cdot \frac{\frac{1}{2}}{a}\right) \cdot \left(a \cdot 4\right)}{\left(-b\right) + \sqrt{-4 \cdot \left(c \cdot a\right) + b \cdot b}}\\ \mathbf{elif}\;b \le 1.8344422394438925 \cdot 10^{+28}:\\ \;\;\;\;\left(\left(-b\right) - \sqrt{-4 \cdot \left(c \cdot a\right) + b \cdot b}\right) \cdot \frac{1}{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

Original33.7
Target20.6
Herbie9.5
\[\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 5 regimes
  2. if b < -3.7781936441701785e+42

    1. Initial program 56.7

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification56.7

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

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

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

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

    if -3.7781936441701785e+42 < b < -5.824809921465728e-67

    1. Initial program 42.7

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification42.7

      \[\leadsto \frac{\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    3. Using strategy rm
    4. Applied flip--42.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}\]
    5. Applied associate-/l/45.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)}}\]
    6. Simplified17.8

      \[\leadsto \frac{\color{blue}{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)}\]

    if -5.824809921465728e-67 < b < -1.1583924904629825e-132

    1. Initial program 30.6

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification30.6

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

      \[\leadsto \color{blue}{\left(\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{2 \cdot a}}\]
    5. Using strategy rm
    6. Applied flip--30.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(-b\right) + \sqrt{b \cdot b + -4 \cdot \left(a \cdot c\right)}}} \cdot \frac{1}{2 \cdot a}\]
    7. Applied associate-*l/30.7

      \[\leadsto \color{blue}{\frac{\left(\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)}\right) \cdot \frac{1}{2 \cdot a}}{\left(-b\right) + \sqrt{b \cdot b + -4 \cdot \left(a \cdot c\right)}}}\]
    8. Simplified16.8

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

    if -1.1583924904629825e-132 < b < 1.8344422394438925e+28

    1. Initial program 12.5

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification12.5

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

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

    if 1.8344422394438925e+28 < b

    1. Initial program 34.1

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification34.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.7781936441701785 \cdot 10^{+42}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le -5.824809921465728 \cdot 10^{-67}:\\ \;\;\;\;\frac{4 \cdot \left(c \cdot a\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) + \sqrt{-4 \cdot \left(c \cdot a\right) + b \cdot b}\right)}\\ \mathbf{elif}\;b \le -1.1583924904629825 \cdot 10^{-132}:\\ \;\;\;\;\frac{\left(c \cdot \frac{\frac{1}{2}}{a}\right) \cdot \left(a \cdot 4\right)}{\left(-b\right) + \sqrt{-4 \cdot \left(c \cdot a\right) + b \cdot b}}\\ \mathbf{elif}\;b \le 1.8344422394438925 \cdot 10^{+28}:\\ \;\;\;\;\left(\left(-b\right) - \sqrt{-4 \cdot \left(c \cdot a\right) + b \cdot b}\right) \cdot \frac{1}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]

Runtime

Time bar (total: 30.6s)Debug logProfile

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