Average Error: 33.6 → 9.9
Time: 2.8m
Precision: 64
Internal Precision: 3392
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\frac{-2}{2}}{b} \le -2.440086329964832 \cdot 10^{+37}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}{2 \cdot a}\\ \mathbf{if}\;\frac{\frac{-2}{2}}{b} \le 3.8986040333535867 \cdot 10^{-308}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{if}\;\frac{\frac{-2}{2}}{b} \le 8.452963334145935 \cdot 10^{-93}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}}{a} \cdot \frac{\sqrt{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}}{2}\\ \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

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

Derivation

  1. Split input into 4 regimes
  2. if (/ (/ -2 2) b) < -2.440086329964832e+37

    1. Initial program 22.9

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

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

    if -2.440086329964832e+37 < (/ (/ -2 2) b) < 3.8986040333535867e-308

    1. Initial program 54.1

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

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

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

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

    if 3.8986040333535867e-308 < (/ (/ -2 2) b) < 8.452963334145935e-93

    1. Initial program 43.3

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}}\]
    4. Applied simplify3.3

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

    if 8.452963334145935e-93 < (/ (/ -2 2) b)

    1. Initial program 9.0

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

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{2 \cdot a}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt9.3

      \[\leadsto \frac{\color{blue}{\sqrt{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b} \cdot \sqrt{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}}}{2 \cdot a}\]
    5. Applied times-frac9.3

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;\frac{\frac{-2}{2}}{b} \le -2.440086329964832 \cdot 10^{+37}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}{2 \cdot a}\\ \mathbf{if}\;\frac{\frac{-2}{2}}{b} \le 3.8986040333535867 \cdot 10^{-308}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{if}\;\frac{\frac{-2}{2}}{b} \le 8.452963334145935 \cdot 10^{-93}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}}{a} \cdot \frac{\sqrt{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}}{2}\\ \end{array}}\]

Runtime

Time bar (total: 2.8m)Debug logProfile

herbie shell --seed 2019053 
(FPCore (a b c)
  :name "The quadratic formula (r1)"

  :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)))