Average Error: 33.6 → 7.1
Time: 5.4s
Precision: binary64
\[\]
\[\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Target

Original33.6
Target20.5
Herbie7.1
\[\]

Derivation

  1. Split input into 4 regimes
  2. if b < -9.13115209614994337e44

    1. Initial program 37.2

      \[\]
    2. Simplified37.2

      \[\leadsto \]
    3. Taylor expanded around -inf 6.0

      \[\leadsto \]
    4. Simplified6.0

      \[\leadsto \]

    if -9.13115209614994337e44 < b < -4.3571849990037956e-308

    1. Initial program 9.2

      \[\]
    2. Simplified9.2

      \[\leadsto \]
    3. Using strategy rm
    4. Applied clear-num9.3

      \[\leadsto \]
    5. Simplified9.3

      \[\leadsto \]

    if -4.3571849990037956e-308 < b < 1.34309843668829568e38

    1. Initial program 28.3

      \[\]
    2. Simplified28.3

      \[\leadsto \]
    3. Using strategy rm
    4. Applied flip-+28.4

      \[\leadsto \]
    5. Simplified16.5

      \[\leadsto \]
    6. Using strategy rm
    7. Applied associate-/r*16.5

      \[\leadsto \]
    8. Simplified9.1

      \[\leadsto \]

    if 1.34309843668829568e38 < b

    1. Initial program 57.0

      \[\]
    2. Simplified57.0

      \[\leadsto \]
    3. Taylor expanded around inf 4.2

      \[\leadsto \]
  3. Recombined 4 regimes into one program.
  4. Final simplification7.1

    \[\leadsto \]

Reproduce

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

  :herbie-target
  (if (< b 0.0) (/ (+ (neg b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ c (* a (/ (- (neg b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))))

  (/ (+ (neg b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))