Average Error: 33.3 → 7.2
Time: 2.0m
Precision: 64
Internal Precision: 3456
\[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;-b \le -6.826309692983647 \cdot 10^{+102}:\\ \;\;\;\;\frac{\frac{4}{2} \cdot c}{\frac{a + a}{\frac{b}{c}} + \left(\left(-b\right) - b\right)}\\ \mathbf{if}\;-b \le -7.696574555670648 \cdot 10^{-204}:\\ \;\;\;\;\frac{1}{\frac{2}{c \cdot 4} \cdot \left(\left(-b\right) - \left(\sqrt[3]{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}} \cdot \sqrt[3]{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}}\right) \cdot \sqrt[3]{\left|\sqrt[3]{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - \left(c \cdot 4\right) \cdot a}}}\right)}\\ \mathbf{if}\;-b \le 2.5728662436638297 \cdot 10^{+45}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c}{b}}{1} - \frac{b}{a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Target

Original33.3
Target20.9
Herbie7.2
\[\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 4 regimes
  2. if (- b) < -6.826309692983647e+102

    1. Initial program 58.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+58.4

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

      \[\leadsto \frac{\frac{\color{blue}{\left(c \cdot a\right) \cdot 4}}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied clear-num33.2

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\frac{\left(c \cdot a\right) \cdot 4}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}}\]
    7. Applied simplify31.2

      \[\leadsto \frac{1}{\color{blue}{\frac{2}{c \cdot 4} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}\right)}}\]
    8. Taylor expanded around inf 7.8

      \[\leadsto \frac{1}{\frac{2}{c \cdot 4} \cdot \left(\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{c \cdot a}{b}\right)}\right)}\]
    9. Applied simplify2.7

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

    if -6.826309692983647e+102 < (- b) < -7.696574555670648e-204

    1. Initial program 36.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+36.5

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

      \[\leadsto \frac{\frac{\color{blue}{\left(c \cdot a\right) \cdot 4}}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied clear-num16.2

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\frac{\left(c \cdot a\right) \cdot 4}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}}\]
    7. Applied simplify7.4

      \[\leadsto \frac{1}{\color{blue}{\frac{2}{c \cdot 4} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}\right)}}\]
    8. Using strategy rm
    9. Applied add-cube-cbrt8.1

      \[\leadsto \frac{1}{\frac{2}{c \cdot 4} \cdot \left(\left(-b\right) - \color{blue}{\left(\sqrt[3]{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}} \cdot \sqrt[3]{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}}\right) \cdot \sqrt[3]{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}}}\right)}\]
    10. Using strategy rm
    11. Applied add-cube-cbrt8.0

      \[\leadsto \frac{1}{\frac{2}{c \cdot 4} \cdot \left(\left(-b\right) - \left(\sqrt[3]{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}} \cdot \sqrt[3]{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}}\right) \cdot \sqrt[3]{\sqrt{\color{blue}{\left(\sqrt[3]{b \cdot b - \left(c \cdot 4\right) \cdot a} \cdot \sqrt[3]{b \cdot b - \left(c \cdot 4\right) \cdot a}\right) \cdot \sqrt[3]{b \cdot b - \left(c \cdot 4\right) \cdot a}}}}\right)}\]
    12. Applied sqrt-prod8.0

      \[\leadsto \frac{1}{\frac{2}{c \cdot 4} \cdot \left(\left(-b\right) - \left(\sqrt[3]{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}} \cdot \sqrt[3]{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}}\right) \cdot \sqrt[3]{\color{blue}{\sqrt{\sqrt[3]{b \cdot b - \left(c \cdot 4\right) \cdot a} \cdot \sqrt[3]{b \cdot b - \left(c \cdot 4\right) \cdot a}} \cdot \sqrt{\sqrt[3]{b \cdot b - \left(c \cdot 4\right) \cdot a}}}}\right)}\]
    13. Applied simplify8.0

      \[\leadsto \frac{1}{\frac{2}{c \cdot 4} \cdot \left(\left(-b\right) - \left(\sqrt[3]{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}} \cdot \sqrt[3]{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}}\right) \cdot \sqrt[3]{\color{blue}{\left|\sqrt[3]{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right|} \cdot \sqrt{\sqrt[3]{b \cdot b - \left(c \cdot 4\right) \cdot a}}}\right)}\]

    if -7.696574555670648e-204 < (- b) < 2.5728662436638297e+45

    1. Initial program 10.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv10.6

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

    if 2.5728662436638297e+45 < (- b)

    1. Initial program 36.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Taylor expanded around -inf 10.7

      \[\leadsto \frac{\color{blue}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}}{2 \cdot a}\]
    3. Applied simplify5.8

      \[\leadsto \color{blue}{\frac{\frac{c}{b}}{1} - \frac{b}{a}}\]
  3. Recombined 4 regimes into one program.

Runtime

Time bar (total: 2.0m)Debug logProfile

herbie shell --seed '#(1064397287 3527694221 3797617954 1138343853 2854031332 1153838279)' 
(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)))