Average Error: 33.5 → 10.4
Time: 1.6m
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 -1.3326732363290293 \cdot 10^{-08}:\\ \;\;\;\;\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}\\ \mathbf{if}\;b_2 \le -3.8704840429822725 \cdot 10^{-70}:\\ \;\;\;\;\log_* (1 + (e^{\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}} - 1)^*)\\ \mathbf{if}\;b_2 \le -1.1366593484846204 \cdot 10^{-98}:\\ \;\;\;\;\log_* (1 + (e^{\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}} - 1)^*)\\ \mathbf{if}\;b_2 \le -6.457435589580916 \cdot 10^{-106}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{if}\;b_2 \le -7.670780076949882 \cdot 10^{-135}:\\ \;\;\;\;\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}\\ \mathbf{if}\;b_2 \le 16578392417.099113:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 5 regimes
  2. if b_2 < -1.3326732363290293e-08 or -6.457435589580916e-106 < b_2 < -7.670780076949882e-135

    1. Initial program 53.2

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

      \[\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 simplify8.2

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

    if -1.3326732363290293e-08 < b_2 < -3.8704840429822725e-70

    1. Initial program 41.3

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

      \[\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 simplify19.4

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

      \[\leadsto \frac{\frac{c \cdot a}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied log1p-expm1-u36.1

      \[\leadsto \color{blue}{\log_* (1 + (e^{\frac{\frac{c \cdot a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}} - 1)^*)}\]
    8. Applied simplify24.1

      \[\leadsto \log_* (1 + \color{blue}{(e^{\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}} - 1)^*})\]

    if -3.8704840429822725e-70 < b_2 < -1.1366593484846204e-98

    1. Initial program 27.7

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

      \[\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 simplify18.3

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

      \[\leadsto \frac{\frac{c \cdot a}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied log1p-expm1-u37.3

      \[\leadsto \color{blue}{\log_* (1 + (e^{\frac{\frac{c \cdot a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}} - 1)^*)}\]
    8. Applied simplify25.0

      \[\leadsto \log_* (1 + \color{blue}{(e^{\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}} - 1)^*})\]

    if -1.1366593484846204e-98 < b_2 < -6.457435589580916e-106 or -7.670780076949882e-135 < b_2 < 16578392417.099113

    1. Initial program 12.0

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

    if 16578392417.099113 < b_2

    1. Initial program 31.9

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

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b_2 \le -1.3326732363290293 \cdot 10^{-08}:\\ \;\;\;\;\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}\\ \mathbf{if}\;b_2 \le -3.8704840429822725 \cdot 10^{-70}:\\ \;\;\;\;\log_* (1 + (e^{\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}} - 1)^*)\\ \mathbf{if}\;b_2 \le -1.1366593484846204 \cdot 10^{-98}:\\ \;\;\;\;\log_* (1 + (e^{\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}} - 1)^*)\\ \mathbf{if}\;b_2 \le -6.457435589580916 \cdot 10^{-106}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{if}\;b_2 \le -7.670780076949882 \cdot 10^{-135}:\\ \;\;\;\;\left(-\frac{1}{2}\right) \cdot \frac{c}{b_2}\\ \mathbf{if}\;b_2 \le 16578392417.099113:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \end{array}}\]

Runtime

Time bar (total: 1.6m)Debug logProfile

herbie shell --seed '#(1071852389 864846987 1238109217 3425890003 4124793586 650694553)' +o rules:numerics
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))