Average Error: 33.1 → 10.3
Time: 1.7m
Precision: 64
Internal Precision: 3392
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -6.76223481168814 \cdot 10^{+153}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \le 1.0563301051488424 \cdot 10^{-103} \lor \neg \left(b \le 3.581490750146723 \cdot 10^{-53}\right) \land b \le 1.5379933112275898 \cdot 10^{-41}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{\sqrt{(\left(-4\right) \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*} - b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{4}{2} \cdot c}{2 \cdot (\left(\frac{a}{b}\right) \cdot c + \left(-b\right))_*}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -6.76223481168814e+153

    1. Initial program 60.7

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

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

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

    if -6.76223481168814e+153 < b < 1.0563301051488424e-103 or 3.581490750146723e-53 < b < 1.5379933112275898e-41

    1. Initial program 12.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity12.0

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

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

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

    if 1.0563301051488424e-103 < b < 3.581490750146723e-53 or 1.5379933112275898e-41 < b

    1. Initial program 51.2

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

      \[\leadsto \frac{\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}}}}{2 \cdot a}\]
    4. Applied associate-/l/52.4

      \[\leadsto \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(2 \cdot a\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}\]
    5. Simplified25.6

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

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

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

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

      \[\leadsto \frac{\frac{4}{2} \cdot c}{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}\]
    12. Simplified10.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -6.76223481168814 \cdot 10^{+153}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \le 1.0563301051488424 \cdot 10^{-103} \lor \neg \left(b \le 3.581490750146723 \cdot 10^{-53}\right) \land b \le 1.5379933112275898 \cdot 10^{-41}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{\sqrt{(\left(-4\right) \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*} - b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{4}{2} \cdot c}{2 \cdot (\left(\frac{a}{b}\right) \cdot c + \left(-b\right))_*}\\ \end{array}\]

Runtime

Time bar (total: 1.7m)Debug logProfile

herbie shell --seed 2018219 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))