Average Error: 33.9 → 13.5
Time: 2.0m
Precision: 64
Internal Precision: 3392
\[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{e^{\left(\sqrt[3]{\log \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)} \cdot \sqrt[3]{\log \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)}\right) \cdot \sqrt[3]{\log \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)}}}{2 \cdot a} \le -5.0932387033100606 \cdot 10^{+302}:\\ \;\;\;\;\frac{c}{b + b} \cdot \frac{-4}{2}\\ \mathbf{elif}\;\frac{e^{\left(\sqrt[3]{\log \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)} \cdot \sqrt[3]{\log \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)}\right) \cdot \sqrt[3]{\log \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)}}}{2 \cdot a} \le -2.4227732924595854 \cdot 10^{-268}:\\ \;\;\;\;\frac{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{2 \cdot a}\\ \mathbf{elif}\;\frac{e^{\left(\sqrt[3]{\log \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)} \cdot \sqrt[3]{\log \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)}\right) \cdot \sqrt[3]{\log \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)}}}{2 \cdot a} \le 4.245273862080992 \cdot 10^{-233}:\\ \;\;\;\;\frac{c}{b + b} \cdot \frac{-4}{2}\\ \mathbf{elif}\;\frac{e^{\left(\sqrt[3]{\log \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)} \cdot \sqrt[3]{\log \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)}\right) \cdot \sqrt[3]{\log \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)}}}{2 \cdot a} \le 2.346181819121296 \cdot 10^{+307}:\\ \;\;\;\;\frac{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b + b} \cdot \frac{-4}{2}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Target

Original33.9
Target21.1
Herbie13.5
\[\begin{array}{l} \mathbf{if}\;b \lt 0:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (exp (* (* (cbrt (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b))) (cbrt (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b)))) (cbrt (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b))))) (* 2 a)) < -5.0932387033100606e+302 or -2.4227732924595854e-268 < (/ (exp (* (* (cbrt (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b))) (cbrt (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b)))) (cbrt (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b))))) (* 2 a)) < 4.245273862080992e-233 or 2.346181819121296e+307 < (/ (exp (* (* (cbrt (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b))) (cbrt (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b)))) (cbrt (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b))))) (* 2 a))

    1. Initial program 58.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Applied simplify58.6

      \[\leadsto \color{blue}{\frac{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{2 \cdot a}}\]
    3. Using strategy rm
    4. Applied div-inv58.6

      \[\leadsto \color{blue}{\left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right) \cdot \frac{1}{2 \cdot a}}\]
    5. Using strategy rm
    6. Applied flip--59.2

      \[\leadsto \color{blue}{\frac{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} \cdot \sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b \cdot b}{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} + b}} \cdot \frac{1}{2 \cdot a}\]
    7. Applied associate-*l/59.2

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

      \[\leadsto \frac{\color{blue}{\frac{\left(a \cdot 4\right) \cdot \left(-c\right)}{2 \cdot a}}}{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} + b}\]
    9. Taylor expanded around 0 28.5

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

      \[\leadsto \color{blue}{\frac{c}{b + b} \cdot \frac{-4}{2}}\]

    if -5.0932387033100606e+302 < (/ (exp (* (* (cbrt (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b))) (cbrt (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b)))) (cbrt (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b))))) (* 2 a)) < -2.4227732924595854e-268 or 4.245273862080992e-233 < (/ (exp (* (* (cbrt (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b))) (cbrt (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b)))) (cbrt (log (- (sqrt (fma (* 4 a) (- c) (* b b))) b))))) (* 2 a)) < 2.346181819121296e+307

    1. Initial program 2.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Applied simplify2.5

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

Runtime

Time bar (total: 2.0m)Debug logProfile

herbie shell --seed 2018208 +o rules:numerics
(FPCore (a b c)
  :name "quadp (p42, positive)"

  :herbie-target
  (if (< b 0) (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))))

  (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))