Average Error: 33.3 → 8.7
Time: 1.3m
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 -8.952883195983225 \cdot 10^{+52}:\\ \;\;\;\;\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}\\ \mathbf{if}\;b_2 \le -6.311680554142015 \cdot 10^{-90}:\\ \;\;\;\;\frac{1}{\frac{a}{\frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\\ \mathbf{if}\;b_2 \le 4.772039586467631 \cdot 10^{+112}:\\ \;\;\;\;\frac{1}{a} \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \end{array}\]

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -8.952883195983225e+52

    1. Initial program 57.1

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

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

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

    if -8.952883195983225e+52 < b_2 < -6.311680554142015e-90

    1. Initial program 41.6

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    4. Using strategy rm
    5. Applied flip--41.7

      \[\leadsto \frac{1}{\frac{a}{\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}}}}}\]
    6. Applied simplify14.9

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

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

    if -6.311680554142015e-90 < b_2 < 4.772039586467631e+112

    1. Initial program 11.8

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

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

    if 4.772039586467631e+112 < b_2

    1. Initial program 47.3

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

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \frac{c \cdot a}{b_2} - 2 \cdot b_2}}{a}\]
    3. Applied simplify3.0

      \[\leadsto \color{blue}{\frac{c}{b_2} \cdot \frac{1}{2} - \frac{b_2}{a} \cdot 2}\]
  3. Recombined 4 regimes into one program.
  4. Applied simplify8.7

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b_2 \le -8.952883195983225 \cdot 10^{+52}:\\ \;\;\;\;\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}\\ \mathbf{if}\;b_2 \le -6.311680554142015 \cdot 10^{-90}:\\ \;\;\;\;\frac{1}{\frac{a}{\frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\\ \mathbf{if}\;b_2 \le 4.772039586467631 \cdot 10^{+112}:\\ \;\;\;\;\frac{1}{a} \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \end{array}}\]

Runtime

Time bar (total: 1.3m)Debug logProfile

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