Average Error: 34.2 → 6.3
Time: 23.8s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -8.422430181155895 \cdot 10^{+146}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le -1.347277676039659 \cdot 10^{-308}:\\ \;\;\;\;\frac{\sqrt{{b}^{2} - 4 \cdot \left(c \cdot a\right)} - b}{a \cdot 2}\\ \mathbf{elif}\;b \le 4.331216038455128 \cdot 10^{+110}:\\ \;\;\;\;\frac{c \cdot -2}{b + \sqrt{b \cdot b - 4 \cdot \left(c \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

Derivation

  1. Split input into 4 regimes
  2. if b < -8.422430181155895e+146

    1. Initial program 57.7

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

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

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

    if -8.422430181155895e+146 < b < -1.347277676039659e-308

    1. Initial program 8.4

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

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

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

    if -1.347277676039659e-308 < b < 4.331216038455128e+110

    1. Initial program 33.8

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(c \cdot -4\right) \cdot a}}{\left(2 \cdot a\right) \cdot \left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b\right)}\]
    7. Using strategy rm
    8. Applied associate-/r*16.1

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

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

    if 4.331216038455128e+110 < b

    1. Initial program 59.2

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -8.422430181155895 \cdot 10^{+146}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le -1.347277676039659 \cdot 10^{-308}:\\ \;\;\;\;\frac{\sqrt{{b}^{2} - 4 \cdot \left(c \cdot a\right)} - b}{a \cdot 2}\\ \mathbf{elif}\;b \le 4.331216038455128 \cdot 10^{+110}:\\ \;\;\;\;\frac{c \cdot -2}{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2018360 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))

Details

Time bar (total: 15.6s)Debug log

start218.0ms

Algorithm
intervals

setup77.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 34.6b

localize39.0ms

Local error

Found 4 expressions with local error:

22.5b
(sqrt (- (* b b) (* (* c a) 4)))
0.9b
(- (sqrt (- (* b b) (* (* c a) 4))) b)
0.4b
(- (* b b) (* (* c a) 4))
0.1b
(/ (- (sqrt (- (* b b) (* (* c a) 4))) b) (* 2 a))

rewrite69.0ms

Algorithm
rewrite-expression-head
Counts
4 → 59
Calls

4 calls. Slowest were:

41.0ms
(/ (- (sqrt (- (* b b) (* (* c a) 4))) b) (* 2 a))
20.0ms
(- (sqrt (- (* b b) (* (* c a) 4))) b)
4.0ms
(- (* b b) (* (* c a) 4))

series247.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

77.0ms
(/ (- (sqrt (- (* b b) (* (* c a) 4))) b) (* 2 a))
74.0ms
(sqrt (- (* b b) (* (* c a) 4)))
64.0ms
(- (sqrt (- (* b b) (* (* c a) 4))) b)
32.0ms
(- (* b b) (* (* c a) 4))

simplify1.9s

Counts
32 → 71
Calls

32 calls. Slowest were:

240.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* c a) 4) 3)))
173.0ms
(- (* (sqrt (- (* b b) (* (* c a) 4))) (sqrt (- (* b b) (* (* c a) 4)))) (* b b))
172.0ms
(- (pow (sqrt (- (* b b) (* (* c a) 4))) 3) (pow b 3))

prune858.0ms

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 4.8b

localize28.0ms

Local error

Found 4 expressions with local error:

22.5b
(sqrt (- (* b b) (* (* c a) 4)))
13.3b
(/ (* (* c -4) a) (* (* 2 a) (+ (sqrt (- (* b b) (* (* c a) 4))) b)))
0.8b
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
0.4b
(- (* b b) (* (* c a) 4))

rewrite49.0ms

Algorithm
rewrite-expression-head
Counts
4 → 55
Calls

4 calls. Slowest were:

24.0ms
(/ (* (* c -4) a) (* (* 2 a) (+ (sqrt (- (* b b) (* (* c a) 4))) b)))
15.0ms
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
4.0ms
(sqrt (- (* b b) (* (* c a) 4)))

series323.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

173.0ms
(/ (* (* c -4) a) (* (* 2 a) (+ (sqrt (- (* b b) (* (* c a) 4))) b)))
57.0ms
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
57.0ms
(sqrt (- (* b b) (* (* c a) 4)))
37.0ms
(- (* b b) (* (* c a) 4))

simplify3.7s

Counts
29 → 67
Calls

29 calls. Slowest were:

820.0ms
(/ (* (* (* (* c -4) a) (* (* c -4) a)) (* (* c -4) a)) (* (* (* (* 2 a) (+ (sqrt (- (* b b) (* (* c a) 4))) b)) (* (* 2 a) (+ (sqrt (- (* b b) (* (* c a) 4))) b))) (* (* 2 a) (+ (sqrt (- (* b b) (* (* c a) 4))) b))))
780.0ms
(/ (* (* (* (* c -4) a) (* (* c -4) a)) (* (* c -4) a)) (* (* (* (* 2 a) (* 2 a)) (* 2 a)) (* (* (+ (sqrt (- (* b b) (* (* c a) 4))) b) (+ (sqrt (- (* b b) (* (* c a) 4))) b)) (+ (sqrt (- (* b b) (* (* c a) 4))) b))))
505.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* c a) 4) (* (* c a) 4))))

prune985.0ms

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 4.7b

localize7.0ms

Local error

Found 4 expressions with local error:

22.5b
(sqrt (- (* b b) (* (* c a) 4)))
12.4b
(/ (* (* c -4) a) (* 2 a))
0.8b
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
0.4b
(- (* b b) (* (* c a) 4))

rewrite18.0ms

Algorithm
rewrite-expression-head
Counts
4 → 51
Calls

4 calls. Slowest were:

8.0ms
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
5.0ms
(/ (* (* c -4) a) (* 2 a))
2.0ms
(- (* b b) (* (* c a) 4))

series158.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

60.0ms
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
46.0ms
(- (* b b) (* (* c a) 4))
43.0ms
(sqrt (- (* b b) (* (* c a) 4)))
8.0ms
(/ (* (* c -4) a) (* 2 a))

simplify2.1s

Counts
24 → 63
Calls

24 calls. Slowest were:

553.0ms
(/ (* (* (* (* c -4) a) (* (* c -4) a)) (* (* c -4) a)) (* (* (* 2 a) (* 2 a)) (* 2 a)))
352.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* c a) 4) 3)))
338.0ms
(- (log (* (* c -4) a)) (log (* 2 a)))

prune1.0s

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 4.7b

localize15.0ms

Local error

Found 4 expressions with local error:

22.5b
(sqrt (- (* b b) (* (* c a) 4)))
0.8b
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
0.4b
(- (* b b) (* (* c a) 4))
0.1b
(/ (* -2 c) (+ (sqrt (- (* b b) (* (* c a) 4))) b))

rewrite47.0ms

Algorithm
rewrite-expression-head
Counts
4 → 57
Calls

4 calls. Slowest were:

22.0ms
(/ (* -2 c) (+ (sqrt (- (* b b) (* (* c a) 4))) b))
15.0ms
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
4.0ms
(sqrt (- (* b b) (* (* c a) 4)))

series303.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

152.0ms
(/ (* -2 c) (+ (sqrt (- (* b b) (* (* c a) 4))) b))
58.0ms
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
57.0ms
(sqrt (- (* b b) (* (* c a) 4)))
36.0ms
(- (* b b) (* (* c a) 4))

simplify1.7s

Counts
32 → 69
Calls

32 calls. Slowest were:

313.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* c a) 4) 3)))
199.0ms
(+ (* (sqrt (- (* b b) (* (* c a) 4))) (sqrt (- (* b b) (* (* c a) 4)))) (- (* b b) (* (sqrt (- (* b b) (* (* c a) 4))) b)))
142.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* c a) 4) (* (* c a) 4))))

prune879.0ms

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 4.7b

regimes289.0ms

Accuracy

96.6% (0.8b remaining)

Error of 6.3b against oracle of 5.5b and baseline of 29.8b

bsearch600.0ms