Average Error: 32.8 → 6.6
Time: 32.2s
Precision: 64
Internal Precision: 3392
\[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -3.3692683081759622 \cdot 10^{+149}:\\ \;\;\;\;\frac{c}{-2 \cdot b_2}\\ \mathbf{elif}\;b_2 \le -2.312521560308525 \cdot 10^{-292}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\\ \mathbf{elif}\;b_2 \le 6.745100626456707 \cdot 10^{+135}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{(b_2 \cdot b_2 + \left(-c \cdot a\right))_*}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b_2\right) - (\left(\frac{c}{b_2} \cdot a\right) \cdot \frac{-1}{2} + b_2)_*}{a}\\ \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 < -3.3692683081759622e+149

    1. Initial program 62.2

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--62.2

      \[\leadsto \frac{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Applied associate-/l/62.2

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

      \[\leadsto \frac{\color{blue}{a \cdot c}}{a \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}\]
    6. Using strategy rm
    7. Applied times-frac38.3

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

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

      \[\leadsto 1 \cdot \color{blue}{\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\]
    10. Using strategy rm
    11. Applied add-exp-log38.4

      \[\leadsto 1 \cdot \frac{c}{\color{blue}{e^{\log \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}}}\]
    12. Taylor expanded around -inf 5.9

      \[\leadsto 1 \cdot \frac{c}{\color{blue}{e^{\log 2 - \log \left(\frac{-1}{b_2}\right)}}}\]
    13. Simplified1.5

      \[\leadsto 1 \cdot \frac{c}{\color{blue}{b_2 \cdot -2}}\]

    if -3.3692683081759622e+149 < b_2 < -2.312521560308525e-292

    1. Initial program 33.5

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--33.6

      \[\leadsto \frac{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Applied associate-/l/37.5

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

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

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

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

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

    if -2.312521560308525e-292 < b_2 < 6.745100626456707e+135

    1. Initial program 9.2

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied fma-neg9.2

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

    if 6.745100626456707e+135 < b_2

    1. Initial program 53.7

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

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{\left(b_2 - \frac{1}{2} \cdot \frac{a \cdot c}{b_2}\right)}}{a}\]
    3. Simplified2.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -3.3692683081759622 \cdot 10^{+149}:\\ \;\;\;\;\frac{c}{-2 \cdot b_2}\\ \mathbf{elif}\;b_2 \le -2.312521560308525 \cdot 10^{-292}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\\ \mathbf{elif}\;b_2 \le 6.745100626456707 \cdot 10^{+135}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{(b_2 \cdot b_2 + \left(-c \cdot a\right))_*}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b_2\right) - (\left(\frac{c}{b_2} \cdot a\right) \cdot \frac{-1}{2} + b_2)_*}{a}\\ \end{array}\]

Runtime

Time bar (total: 32.2s)Debug logProfile

herbie shell --seed 2018235 +o rules:numerics
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))