Average Error: 33.5 → 7.1
Time: 24.4s
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 -4.209504678355017 \cdot 10^{+65}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le -5.15631482418829 \cdot 10^{-230}:\\ \;\;\;\;\frac{\sqrt{{b}^{2} - \left(c \cdot a\right) \cdot 4} - b}{a \cdot 2}\\ \mathbf{elif}\;b \le 1.0547782469042754 \cdot 10^{+108}:\\ \;\;\;\;\frac{-2}{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b}{c}}\\ \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 < -4.209504678355017e+65

    1. Initial program 39.8

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

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

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

    if -4.209504678355017e+65 < b < -5.15631482418829e-230

    1. Initial program 8.7

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

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

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

    if -5.15631482418829e-230 < b < 1.0547782469042754e+108

    1. Initial program 29.7

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

      \[\leadsto \frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{2 \cdot a}\]
    3. Using strategy rm
    4. Applied flip--29.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/34.7

      \[\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*15.9

      \[\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.8

      \[\leadsto \frac{\color{blue}{-2 \cdot c}}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b}\]
    10. Using strategy rm
    11. Applied associate-/l*10.1

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

    if 1.0547782469042754e+108 < b

    1. Initial program 59.1

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.209504678355017 \cdot 10^{+65}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le -5.15631482418829 \cdot 10^{-230}:\\ \;\;\;\;\frac{\sqrt{{b}^{2} - \left(c \cdot a\right) \cdot 4} - b}{a \cdot 2}\\ \mathbf{elif}\;b \le 1.0547782469042754 \cdot 10^{+108}:\\ \;\;\;\;\frac{-2}{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 17.2s)Debug log

start201.0ms

Algorithm
intervals

setup122.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 35.7b

localize40.0ms

Local error

Found 4 expressions with local error:

25.1b
(sqrt (- (* b b) (* (* c a) 4)))
1.2b
(- (sqrt (- (* b b) (* (* c a) 4))) b)
0.8b
(- (* b b) (* (* c a) 4))
0.1b
(/ (- (sqrt (- (* b b) (* (* c a) 4))) b) (* 2 a))

rewrite50.0ms

Algorithm
rewrite-expression-head
Counts
4 → 59
Calls

4 calls. Slowest were:

27.0ms
(/ (- (sqrt (- (* b b) (* (* c a) 4))) b) (* 2 a))
16.0ms
(- (sqrt (- (* b b) (* (* c a) 4))) b)
4.0ms
(sqrt (- (* b b) (* (* c a) 4)))

series243.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

78.0ms
(- (sqrt (- (* b b) (* (* c a) 4))) b)
74.0ms
(/ (- (sqrt (- (* b b) (* (* c a) 4))) b) (* 2 a))
47.0ms
(sqrt (- (* b b) (* (* c a) 4)))
44.0ms
(- (* b b) (* (* c a) 4))

simplify2.3s

Counts
32 → 71
Calls

32 calls. Slowest were:

418.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* c a) 4) 3)))
302.0ms
(- (* (sqrt (- (* b b) (* (* c a) 4))) (sqrt (- (* b b) (* (* c a) 4)))) (* b b))
196.0ms
(- (pow (sqrt (- (* b b) (* (* c a) 4))) 3) (pow b 3))

prune1.0s

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 5.9b

localize27.0ms

Local error

Found 4 expressions with local error:

25.1b
(sqrt (- (* b b) (* (* c a) 4)))
17.5b
(/ (* (* c -4) a) (* (* 2 a) (+ (sqrt (- (* b b) (* (* c a) 4))) b)))
1.2b
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
0.8b
(- (* b b) (* (* c a) 4))

rewrite47.0ms

Algorithm
rewrite-expression-head
Counts
4 → 55
Calls

4 calls. Slowest were:

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

series320.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

148.0ms
(/ (* (* c -4) a) (* (* 2 a) (+ (sqrt (- (* b b) (* (* c a) 4))) b)))
74.0ms
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
69.0ms
(sqrt (- (* b b) (* (* c a) 4)))
30.0ms
(- (* b b) (* (* c a) 4))

simplify4.2s

Counts
29 → 67
Calls

29 calls. Slowest were:

1.3s
(/ (* (* (* (* 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))))
928.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))))
336.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* c a) 4) 3)))

prune1.1s

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 5.9b

localize6.0ms

Local error

Found 4 expressions with local error:

25.1b
(sqrt (- (* b b) (* (* c a) 4)))
14.6b
(/ (* (* c -4) a) (* 2 a))
1.2b
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
0.8b
(- (* b b) (* (* c a) 4))

rewrite20.0ms

Algorithm
rewrite-expression-head
Counts
4 → 51
Calls

4 calls. Slowest were:

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

series133.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

57.0ms
(sqrt (- (* b b) (* (* c a) 4)))
44.0ms
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
27.0ms
(- (* b b) (* (* c a) 4))
5.0ms
(/ (* (* c -4) a) (* 2 a))

simplify2.4s

Counts
24 → 63
Calls

24 calls. Slowest were:

794.0ms
(- (log (* (* c -4) a)) (log (* 2 a)))
466.0ms
(/ (* (* (* (* c -4) a) (* (* c -4) a)) (* (* c -4) a)) (* (* (* 2 a) (* 2 a)) (* 2 a)))
349.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* c a) 4) 3)))

prune971.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 5.9b

localize12.0ms

Local error

Found 4 expressions with local error:

25.1b
(sqrt (- (* b b) (* (* c a) 4)))
1.2b
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
0.8b
(- (* b b) (* (* c a) 4))
0.4b
(/ (* -2 c) (+ (sqrt (- (* b b) (* (* c a) 4))) b))

rewrite27.0ms

Algorithm
rewrite-expression-head
Counts
4 → 57
Calls

4 calls. Slowest were:

11.0ms
(/ (* -2 c) (+ (sqrt (- (* b b) (* (* c a) 4))) b))
10.0ms
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
4.0ms
(sqrt (- (* b b) (* (* c a) 4)))

series290.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

115.0ms
(/ (* -2 c) (+ (sqrt (- (* b b) (* (* c a) 4))) b))
73.0ms
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
60.0ms
(sqrt (- (* b b) (* (* c a) 4)))
42.0ms
(- (* b b) (* (* c a) 4))

simplify2.1s

Counts
32 → 69
Calls

32 calls. Slowest were:

435.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* c a) 4) 3)))
271.0ms
(+ (* (sqrt (- (* b b) (* (* c a) 4))) (sqrt (- (* b b) (* (* c a) 4)))) (- (* b b) (* (sqrt (- (* b b) (* (* c a) 4))) b)))
160.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* c a) 4) (* (* c a) 4))))

prune829.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 5.9b

regimes298.0ms

Accuracy

94.1% (1.4b remaining)

Error of 7.1b against oracle of 5.7b and baseline of 29.2b

bsearch600.0ms