Average Error: 33.5 → 6.7
Time: 50.0s
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 -6.269787584020147 \cdot 10^{+84}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le 2.9698792885451 \cdot 10^{-310}:\\ \;\;\;\;\frac{\frac{c}{\frac{1}{2}}}{\sqrt{a \cdot \left(-4 \cdot c\right) + b \cdot b} - b}\\ \mathbf{elif}\;b \le 1.3586174053149808 \cdot 10^{+85}:\\ \;\;\;\;\left(\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)}\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.5
Target20.8
Herbie6.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 < -6.269787584020147e+84

    1. Initial program 57.9

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

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

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

    if -6.269787584020147e+84 < b < 2.9698792885451e-310

    1. Initial program 30.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 sub-neg30.2

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\left(a \cdot c\right) \cdot 4}{2 \cdot a}}}{\left(-b\right) + \sqrt{b \cdot b + \left(-4 \cdot \left(a \cdot c\right)\right)}}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity15.6

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

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

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

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

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

    if 2.9698792885451e-310 < b < 1.3586174053149808e+85

    1. Initial program 9.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 sub-neg9.7

      \[\leadsto \frac{\left(-b\right) - \sqrt{\color{blue}{b \cdot b + \left(-4 \cdot \left(a \cdot c\right)\right)}}}{2 \cdot a}\]
    4. Using strategy rm
    5. Applied div-inv9.8

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

    if 1.3586174053149808e+85 < b

    1. Initial program 42.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 sub-neg42.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -6.269787584020147 \cdot 10^{+84}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le 2.9698792885451 \cdot 10^{-310}:\\ \;\;\;\;\frac{\frac{c}{\frac{1}{2}}}{\sqrt{a \cdot \left(-4 \cdot c\right) + b \cdot b} - b}\\ \mathbf{elif}\;b \le 1.3586174053149808 \cdot 10^{+85}:\\ \;\;\;\;\left(\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)}\right) \cdot \frac{1}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]

Runtime

Time bar (total: 50.0s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes29.66.75.723.995.6%
herbie shell --seed 2018274 
(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)))