Average Error: 32.8 → 9.1
Time: 23.7s
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}\;b \le -2.1052071487533018 \cdot 10^{+151}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a} \cdot \frac{1}{2}\right) - \frac{b}{2 \cdot a}\\ \mathbf{elif}\;b \le 3.9264312060713937 \cdot 10^{-109}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}{2 \cdot a} - \frac{b}{2 \cdot a}\\ \mathbf{elif}\;b \le 6.187862221505769 \cdot 10^{+40}:\\ \;\;\;\;\frac{\left(c \cdot -4\right) \cdot a}{\left(b + \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\right) \cdot \left(2 \cdot a\right)}\\ \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.8
Target20.3
Herbie9.1
\[\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 < -2.1052071487533018e+151

    1. Initial program 60.1

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

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

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

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

    if -2.1052071487533018e+151 < b < 3.9264312060713937e-109

    1. Initial program 10.7

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

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

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

    if 3.9264312060713937e-109 < b < 6.187862221505769e+40

    1. Initial program 38.5

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

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

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

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

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

    if 6.187862221505769e+40 < b

    1. Initial program 55.9

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.1052071487533018 \cdot 10^{+151}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a} \cdot \frac{1}{2}\right) - \frac{b}{2 \cdot a}\\ \mathbf{elif}\;b \le 3.9264312060713937 \cdot 10^{-109}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}{2 \cdot a} - \frac{b}{2 \cdot a}\\ \mathbf{elif}\;b \le 6.187862221505769 \cdot 10^{+40}:\\ \;\;\;\;\frac{\left(c \cdot -4\right) \cdot a}{\left(b + \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\right) \cdot \left(2 \cdot a\right)}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Runtime

Time bar (total: 23.7s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes33.19.15.627.587.5%
herbie shell --seed 2018296 
(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)))