Average Error: 33.6 → 9.8
Time: 4.3m
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 -4.145680582588426 \cdot 10^{+97}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{if}\;-b \le 4.068478382870796 \cdot 10^{-77}:\\ \;\;\;\;\frac{1}{a \cdot 2} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\\ \mathbf{if}\;-b \le 1.8248139046333156 \cdot 10^{+68}:\\ \;\;\;\;\frac{\frac{4}{\sqrt{\sqrt{b \cdot b - a \cdot \left(4 \cdot c\right)} - b}}}{a} \cdot \frac{\frac{a \cdot c}{\sqrt{\sqrt{b \cdot b - a \cdot \left(4 \cdot c\right)} - b}}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{4}{2} \cdot c}{\frac{c \cdot 2}{\frac{b}{a}} - \left(b + b\right)}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Target

Original33.6
Target20.7
Herbie9.8
\[\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) < -4.145680582588426e+97

    1. Initial program 44.2

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

      \[\leadsto \frac{\color{blue}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}}{2 \cdot a}\]
    3. Applied simplify4.3

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

    if -4.145680582588426e+97 < (- b) < 4.068478382870796e-77

    1. Initial program 13.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 div-inv13.2

      \[\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 4.068478382870796e-77 < (- b) < 1.8248139046333156e+68

    1. Initial program 41.3

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

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

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

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

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

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

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

    if 1.8248139046333156e+68 < (- b)

    1. Initial program 58.3

      \[\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--58.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 simplify30.7

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

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

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

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

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

      \[\leadsto \frac{\frac{c \cdot a}{1}}{\frac{2 \cdot a}{\frac{4}{\color{blue}{\left(2 \cdot \frac{c \cdot a}{b} - b\right)} - b}}}\]
    11. Applied simplify3.9

      \[\leadsto \color{blue}{\frac{c \cdot \frac{4}{2}}{\frac{2 \cdot c}{\frac{b}{a}} - \left(b + b\right)}}\]
  3. Recombined 4 regimes into one program.
  4. Applied simplify9.8

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;-b \le -4.145680582588426 \cdot 10^{+97}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{if}\;-b \le 4.068478382870796 \cdot 10^{-77}:\\ \;\;\;\;\frac{1}{a \cdot 2} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\\ \mathbf{if}\;-b \le 1.8248139046333156 \cdot 10^{+68}:\\ \;\;\;\;\frac{\frac{4}{\sqrt{\sqrt{b \cdot b - a \cdot \left(4 \cdot c\right)} - b}}}{a} \cdot \frac{\frac{a \cdot c}{\sqrt{\sqrt{b \cdot b - a \cdot \left(4 \cdot c\right)} - b}}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{4}{2} \cdot c}{\frac{c \cdot 2}{\frac{b}{a}} - \left(b + b\right)}\\ \end{array}}\]

Runtime

Time bar (total: 4.3m)Debug logProfile

herbie shell --seed '#(1071725047 233389029 2036512464 3988615230 2972226563 1111574017)' 
(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)))