Average Error: 32.9 → 9.0
Time: 37.8s
Precision: 64
Internal Precision: 128
\[\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 -1.3801296442484604 \cdot 10^{+103}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 7.397988601404757 \cdot 10^{-150}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(-4 \cdot a\right)} - b}{a \cdot 2}\\ \mathbf{elif}\;b \le 2.7301022051416326 \cdot 10^{+115}:\\ \;\;\;\;\left(\left(\sqrt[3]{\frac{\frac{1}{2}}{a}} \cdot \sqrt[3]{\frac{\frac{1}{2}}{a}}\right) \cdot \left(-4 \cdot \left(c \cdot a\right)\right)\right) \cdot \frac{\sqrt[3]{\frac{\frac{1}{2}}{a}}}{b + \sqrt{-4 \cdot \left(c \cdot a\right) + b \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original32.9
Target20.6
Herbie9.0
\[\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 < -1.3801296442484604e+103

    1. Initial program 46.2

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

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

      \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}}\]

    if -1.3801296442484604e+103 < b < 7.397988601404757e-150

    1. Initial program 11.2

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

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

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

    if 7.397988601404757e-150 < b < 2.7301022051416326e+115

    1. Initial program 38.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification38.7

      \[\leadsto \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2 \cdot a}\]
    3. Using strategy rm
    4. Applied sub-neg38.7

      \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b + \left(-\left(4 \cdot a\right) \cdot c\right)}} - b}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity38.7

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

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

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

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

      \[\leadsto \frac{\frac{1}{2 \cdot a}}{\color{blue}{\frac{1}{\sqrt{\left(a \cdot -4\right) \cdot c + b \cdot b} - b}}}\]
    12. Using strategy rm
    13. Applied flip--38.8

      \[\leadsto \frac{\frac{1}{2 \cdot a}}{\frac{1}{\color{blue}{\frac{\sqrt{\left(a \cdot -4\right) \cdot c + b \cdot b} \cdot \sqrt{\left(a \cdot -4\right) \cdot c + b \cdot b} - b \cdot b}{\sqrt{\left(a \cdot -4\right) \cdot c + b \cdot b} + b}}}}\]
    14. Applied associate-/r/38.8

      \[\leadsto \frac{\frac{1}{2 \cdot a}}{\color{blue}{\frac{1}{\sqrt{\left(a \cdot -4\right) \cdot c + b \cdot b} \cdot \sqrt{\left(a \cdot -4\right) \cdot c + b \cdot b} - b \cdot b} \cdot \left(\sqrt{\left(a \cdot -4\right) \cdot c + b \cdot b} + b\right)}}\]
    15. Applied add-cube-cbrt39.0

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

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

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

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

    if 2.7301022051416326e+115 < b

    1. Initial program 59.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification59.3

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    6. Simplified1.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.3801296442484604 \cdot 10^{+103}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 7.397988601404757 \cdot 10^{-150}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(-4 \cdot a\right)} - b}{a \cdot 2}\\ \mathbf{elif}\;b \le 2.7301022051416326 \cdot 10^{+115}:\\ \;\;\;\;\left(\left(\sqrt[3]{\frac{\frac{1}{2}}{a}} \cdot \sqrt[3]{\frac{\frac{1}{2}}{a}}\right) \cdot \left(-4 \cdot \left(c \cdot a\right)\right)\right) \cdot \frac{\sqrt[3]{\frac{\frac{1}{2}}{a}}}{b + \sqrt{-4 \cdot \left(c \cdot a\right) + b \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Runtime

Time bar (total: 37.8s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes32.09.05.726.387.3%
herbie shell --seed 2018352 
(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)))