Average Error: 34.1 → 7.1
Time: 3.5m
Precision: 64
Internal Precision: 128
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -9.819658654278669 \cdot 10^{+101}:\\ \;\;\;\;\frac{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(b_2 \cdot -2\right))_*}{a}\\ \mathbf{elif}\;b_2 \le -2.3322747220103687 \cdot 10^{-296}:\\ \;\;\;\;\frac{\sqrt{(\left(\sqrt[3]{b_2 \cdot b_2} \cdot \sqrt[3]{b_2 \cdot b_2}\right) \cdot \left(\sqrt[3]{b_2 \cdot b_2}\right) + \left(a \cdot \left(-c\right)\right))_*} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 5.1457556548524475 \cdot 10^{+64}:\\ \;\;\;\;\frac{-c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{(\left(c \cdot \frac{a}{b_2}\right) \cdot \frac{-1}{2} + \left(b_2 \cdot 2\right))_*}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -9.819658654278669e+101

    1. Initial program 44.9

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified44.9

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around -inf 10.4

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \frac{a \cdot c}{b_2} - 2 \cdot b_2}}{a}\]
    4. Simplified3.8

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

    if -9.819658654278669e+101 < b_2 < -2.3322747220103687e-296

    1. Initial program 9.6

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified9.6

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt9.7

      \[\leadsto \frac{\sqrt{\color{blue}{\left(\sqrt[3]{b_2 \cdot b_2} \cdot \sqrt[3]{b_2 \cdot b_2}\right) \cdot \sqrt[3]{b_2 \cdot b_2}} - a \cdot c} - b_2}{a}\]
    5. Applied fma-neg9.7

      \[\leadsto \frac{\sqrt{\color{blue}{(\left(\sqrt[3]{b_2 \cdot b_2} \cdot \sqrt[3]{b_2 \cdot b_2}\right) \cdot \left(\sqrt[3]{b_2 \cdot b_2}\right) + \left(-a \cdot c\right))_*}} - b_2}{a}\]

    if -2.3322747220103687e-296 < b_2 < 5.1457556548524475e+64

    1. Initial program 30.5

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified30.5

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied flip--30.6

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}}{a}\]
    5. Applied associate-/l/35.5

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{a \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}}\]
    6. Simplified22.4

      \[\leadsto \frac{\color{blue}{-a \cdot c}}{a \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}\]
    7. Using strategy rm
    8. Applied distribute-frac-neg22.4

      \[\leadsto \color{blue}{-\frac{a \cdot c}{a \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}}\]
    9. Simplified10.1

      \[\leadsto -\color{blue}{\frac{c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]

    if 5.1457556548524475e+64 < b_2

    1. Initial program 57.4

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified57.4

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied flip--57.5

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}}{a}\]
    5. Applied associate-/l/57.8

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{a \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}}\]
    6. Simplified29.8

      \[\leadsto \frac{\color{blue}{-a \cdot c}}{a \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}\]
    7. Using strategy rm
    8. Applied distribute-frac-neg29.8

      \[\leadsto \color{blue}{-\frac{a \cdot c}{a \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}}\]
    9. Simplified26.6

      \[\leadsto -\color{blue}{\frac{c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    10. Taylor expanded around inf 6.4

      \[\leadsto -\frac{c}{\color{blue}{2 \cdot b_2 - \frac{1}{2} \cdot \frac{a \cdot c}{b_2}}}\]
    11. Simplified3.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -9.819658654278669 \cdot 10^{+101}:\\ \;\;\;\;\frac{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(b_2 \cdot -2\right))_*}{a}\\ \mathbf{elif}\;b_2 \le -2.3322747220103687 \cdot 10^{-296}:\\ \;\;\;\;\frac{\sqrt{(\left(\sqrt[3]{b_2 \cdot b_2} \cdot \sqrt[3]{b_2 \cdot b_2}\right) \cdot \left(\sqrt[3]{b_2 \cdot b_2}\right) + \left(a \cdot \left(-c\right)\right))_*} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 5.1457556548524475 \cdot 10^{+64}:\\ \;\;\;\;\frac{-c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{(\left(c \cdot \frac{a}{b_2}\right) \cdot \frac{-1}{2} + \left(b_2 \cdot 2\right))_*}\\ \end{array}\]

Reproduce

herbie shell --seed 2019088 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))