Average Error: 32.7 → 8.2
Time: 17.9s
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 -7.0744040414122835 \cdot 10^{+130}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 4.270340906482378 \cdot 10^{-114}:\\ \;\;\;\;\frac{\sqrt{{b}^{2} - 4 \cdot \left(c \cdot a\right)} - b}{a \cdot 2}\\ \mathbf{elif}\;b \le 2.205823585814744 \cdot 10^{+105}:\\ \;\;\;\;\frac{c \cdot -4}{\frac{\left(b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right) \cdot \left(a \cdot 2\right)}{a}}\\ \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 < -7.0744040414122835e+130

    1. Initial program 53.0

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

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

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

    if -7.0744040414122835e+130 < b < 4.270340906482378e-114

    1. Initial program 11.4

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

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

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

    if 4.270340906482378e-114 < b < 2.205823585814744e+105

    1. Initial program 39.9

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

      \[\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 flip--39.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/42.6

      \[\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. Simplified16.4

      \[\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-/l*10.8

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

    if 2.205823585814744e+105 < b

    1. Initial program 58.9

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

      \[\leadsto \color{blue}{\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 simplification8.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -7.0744040414122835 \cdot 10^{+130}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 4.270340906482378 \cdot 10^{-114}:\\ \;\;\;\;\frac{\sqrt{{b}^{2} - 4 \cdot \left(c \cdot a\right)} - b}{a \cdot 2}\\ \mathbf{elif}\;b \le 2.205823585814744 \cdot 10^{+105}:\\ \;\;\;\;\frac{c \cdot -4}{\frac{\left(b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right) \cdot \left(a \cdot 2\right)}{a}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 17.1s)Debug log

sample227.0ms

Algorithm
intervals

simplify90.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

90.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))

prune20.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 37.0b

localize52.0ms

Local error

Found 4 expressions with local error:

23.6b
(sqrt (- (* b b) (* (* c a) 4)))
1.3b
(- (sqrt (- (* b b) (* (* c a) 4))) b)
0.6b
(- (* 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:

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

series215.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

87.0ms
(/ (- (sqrt (- (* b b) (* (* c a) 4))) b) (* 2 a))
60.0ms
(sqrt (- (* b b) (* (* c a) 4)))
43.0ms
(- (sqrt (- (* b b) (* (* c a) 4))) b)
25.0ms
(- (* b b) (* (* c a) 4))

simplify2.0s

Counts
32 → 71
Calls

32 calls. Slowest were:

344.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* c a) 4) 3)))
265.0ms
(- (* (sqrt (- (* b b) (* (* c a) 4))) (sqrt (- (* b b) (* (* c a) 4)))) (* b b))
191.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* c a) 4) (* (* c a) 4))))

prune862.0ms

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 4.5b

localize14.0ms

Local error

Found 4 expressions with local error:

23.6b
(sqrt (- (* b b) (* (* c a) 4)))
14.2b
(/ (* (* c -4) a) (* (* 2 a) (+ (sqrt (- (* b b) (* (* c a) 4))) b)))
1.7b
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
0.6b
(- (* b b) (* (* c a) 4))

rewrite26.0ms

Algorithm
rewrite-expression-head
Counts
4 → 55
Calls

4 calls. Slowest were:

14.0ms
(/ (* (* c -4) a) (* (* 2 a) (+ (sqrt (- (* b b) (* (* c a) 4))) b)))
7.0ms
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
2.0ms
(- (* b b) (* (* c a) 4))

series300.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

169.0ms
(/ (* (* c -4) a) (* (* 2 a) (+ (sqrt (- (* b b) (* (* c a) 4))) b)))
58.0ms
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
45.0ms
(sqrt (- (* b b) (* (* c a) 4)))
29.0ms
(- (* b b) (* (* c a) 4))

simplify3.7s

Counts
29 → 67
Calls

29 calls. Slowest were:

994.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))))
832.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))))
358.0ms
(+ (* (sqrt (- (* b b) (* (* c a) 4))) (sqrt (- (* b b) (* (* c a) 4)))) (- (* b b) (* (sqrt (- (* b b) (* (* c a) 4))) b)))

prune813.0ms

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 4.5b

localize12.0ms

Local error

Found 4 expressions with local error:

23.6b
(sqrt (- (* b b) (* (* c a) 4)))
10.5b
(/ (* (* 2 a) (+ (sqrt (- (* b b) (* (* c a) 4))) b)) a)
1.7b
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
0.6b
(- (* b b) (* (* c a) 4))

rewrite52.0ms

Algorithm
rewrite-expression-head
Counts
4 → 49
Calls

4 calls. Slowest were:

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

series221.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

74.0ms
(/ (* (* 2 a) (+ (sqrt (- (* b b) (* (* c a) 4))) b)) a)
65.0ms
(+ (sqrt (- (* b b) (* (* c a) 4))) b)
47.0ms
(sqrt (- (* b b) (* (* c a) 4)))
35.0ms
(- (* b b) (* (* c a) 4))

simplify1.6s

Counts
22 → 61
Calls

22 calls. Slowest were:

386.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* c a) 4) 3)))
185.0ms
(* (* 2 a) (- (* (sqrt (- (* b b) (* (* c a) 4))) (sqrt (- (* b b) (* (* c a) 4)))) (* b b)))
146.0ms
(- b (* 2 (/ (* a c) b)))

prune730.0ms

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 4.5b

localize10.0ms

Local error

Found 0 expressions with local error:

rewrite0.0ms

Algorithm
rewrite-expression-head
Counts
0 → 0
Calls

0 calls. Slowest were:

series0.0ms

Counts
0 → 0
Calls

0 calls. Slowest were:

simplify0.0ms

Counts
0 → 0
Calls

0 calls. Slowest were:

prune1.0ms

Pruning

7 alts after pruning (4 fresh and 3 done)

Merged error: 4.5b

regimes456.0ms

Accuracy

90.7% (2.6b remaining)

Error of 8.2b against oracle of 5.6b and baseline of 33.1b

bsearch618.0ms

end0.0ms

sample5.1s

Algorithm
intervals