Average Error: 33.3 → 9.7
Time: 23.9s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.7715196556134555 \cdot 10^{+46}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le -1.1090157738250754 \cdot 10^{-76}:\\ \;\;\;\;\frac{\left(a \cdot c\right) \cdot 4}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) + \sqrt{{b}^{2} - \left(a \cdot c\right) \cdot 4}\right)}\\ \mathbf{elif}\;b \le 5.973421650485517 \cdot 10^{+105}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{{b}^{2} - \left(a \cdot c\right) \cdot 4}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \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.3
Target20.4
Herbie9.7
\[\begin{array}{l} \mathbf{if}\;b \lt 0:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \end{array}\]

Derivation

  1. Split input into 4 regimes
  2. if b < -1.7715196556134555e+46

    1. Initial program 56.2

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    3. Simplified4.3

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

    if -1.7715196556134555e+46 < b < -1.1090157738250754e-76

    1. Initial program 42.2

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Taylor expanded around 0 42.2

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

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

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

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

    if -1.1090157738250754e-76 < b < 5.973421650485517e+105

    1. Initial program 13.0

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Taylor expanded around 0 13.0

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

    if 5.973421650485517e+105 < b

    1. Initial program 46.5

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Taylor expanded around 0 46.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.7715196556134555 \cdot 10^{+46}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le -1.1090157738250754 \cdot 10^{-76}:\\ \;\;\;\;\frac{\left(a \cdot c\right) \cdot 4}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) + \sqrt{{b}^{2} - \left(a \cdot c\right) \cdot 4}\right)}\\ \mathbf{elif}\;b \le 5.973421650485517 \cdot 10^{+105}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{{b}^{2} - \left(a \cdot c\right) \cdot 4}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019002 
(FPCore (a b c)
  :name "quadm (p42, negative)"

  :herbie-target
  (if (< b 0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))

  (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))

Details

Time bar (total: 23.1s)Debug log

sample110.0ms

Algorithm
intervals

simplify83.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune19.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 32.3b

localize49.0ms

Local error

Found 4 expressions with local error:

22.2b
(sqrt (- (* b b) (* 4 (* a c))))
1.9b
(- (- b) (sqrt (- (* b b) (* 4 (* a c)))))
0.6b
(- (* b b) (* 4 (* a c)))
0.1b
(/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a))

rewrite51.0ms

Algorithm
rewrite-expression-head
Counts
4 → 70
Calls

4 calls. Slowest were:

30.0ms
(/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a))
11.0ms
(- (- b) (sqrt (- (* b b) (* 4 (* a c)))))
5.0ms
(- (* b b) (* 4 (* a c)))

series238.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

72.0ms
(sqrt (- (* b b) (* 4 (* a c))))
69.0ms
(/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a))
55.0ms
(- (- b) (sqrt (- (* b b) (* 4 (* a c)))))
42.0ms
(- (* b b) (* 4 (* a c)))

simplify3.0s

Counts
46 → 82
Calls

46 calls. Slowest were:

326.0ms
(sqrt (- (pow (* b b) 3) (pow (* 4 (* a c)) 3)))
316.0ms
(- (* (- b) (- b)) (* (sqrt (- (* b b) (* 4 (* a c)))) (sqrt (- (* b b) (* 4 (* a c))))))
305.0ms
(- (pow (- b) 3) (pow (sqrt (- (* b b) (* 4 (* a c)))) 3))

prune924.0ms

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 5.0b

localize13.0ms

Local error

Found 4 expressions with local error:

22.2b
(sqrt (- (pow b 2) (* 4 (* a c))))
1.9b
(- (- b) (sqrt (- (pow b 2) (* 4 (* a c)))))
0.6b
(- (pow b 2) (* 4 (* a c)))
0.1b
(/ (- (- b) (sqrt (- (pow b 2) (* 4 (* a c))))) (* 2 a))

rewrite45.0ms

Algorithm
rewrite-expression-head
Counts
4 → 70
Calls

4 calls. Slowest were:

32.0ms
(/ (- (- b) (sqrt (- (pow b 2) (* 4 (* a c))))) (* 2 a))
7.0ms
(- (- b) (sqrt (- (pow b 2) (* 4 (* a c)))))
3.0ms
(- (pow b 2) (* 4 (* a c)))

series202.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

76.0ms
(/ (- (- b) (sqrt (- (pow b 2) (* 4 (* a c))))) (* 2 a))
57.0ms
(- (- b) (sqrt (- (pow b 2) (* 4 (* a c)))))
42.0ms
(sqrt (- (pow b 2) (* 4 (* a c))))
27.0ms
(- (pow b 2) (* 4 (* a c)))

simplify3.8s

Counts
46 → 82
Calls

46 calls. Slowest were:

1.1s
(- (* (- b) (- b)) (* (sqrt (- (pow b 2) (* 4 (* a c)))) (sqrt (- (pow b 2) (* 4 (* a c))))))
360.0ms
(sqrt (- (pow (pow b 2) 3) (pow (* 4 (* a c)) 3)))
223.0ms
(- (pow (- b) 3) (pow (sqrt (- (pow b 2) (* 4 (* a c)))) 3))

prune862.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 5.0b

localize10.0ms

Local error

Found 4 expressions with local error:

22.2b
(sqrt (- (* b b) (* 4 (* a c))))
1.9b
(- (- b) (sqrt (- (* b b) (* 4 (* a c)))))
0.6b
(- (* b b) (* 4 (* a c)))
0.2b
(/ 1 (/ (* 2 a) (- (- b) (sqrt (- (* b b) (* 4 (* a c)))))))

rewrite31.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

10.0ms
(- (- b) (sqrt (- (* b b) (* 4 (* a c)))))
9.0ms
(/ 1 (/ (* 2 a) (- (- b) (sqrt (- (* b b) (* 4 (* a c)))))))
7.0ms
(- (* b b) (* 4 (* a c)))

series241.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

81.0ms
(/ 1 (/ (* 2 a) (- (- b) (sqrt (- (* b b) (* 4 (* a c)))))))
69.0ms
(- (- b) (sqrt (- (* b b) (* 4 (* a c)))))
62.0ms
(sqrt (- (* b b) (* 4 (* a c))))
29.0ms
(- (* b b) (* 4 (* a c)))

simplify1.9s

Counts
39 → 81
Calls

39 calls. Slowest were:

291.0ms
(sqrt (- (pow (* b b) 3) (pow (* 4 (* a c)) 3)))
281.0ms
(+ (* (- b) (- b)) (+ (* (sqrt (- (* b b) (* 4 (* a c)))) (sqrt (- (* b b) (* 4 (* a c))))) (* (- b) (sqrt (- (* b b) (* 4 (* a c)))))))
115.0ms
(sqrt (- (* (* b b) (* b b)) (* (* 4 (* a c)) (* 4 (* a c)))))

prune939.0ms

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 5.0b

localize30.0ms

Local error

Found 4 expressions with local error:

22.2b
(sqrt (- (pow b 2) (* 4 (* a c))))
15.4b
(/ (* (* c a) 4) (* (* 2 a) (+ (- b) (sqrt (- (pow b 2) (* 4 (* a c)))))))
1.3b
(+ (- b) (sqrt (- (pow b 2) (* 4 (* a c)))))
0.6b
(- (pow b 2) (* 4 (* a c)))

rewrite31.0ms

Algorithm
rewrite-expression-head
Counts
4 → 58
Calls

4 calls. Slowest were:

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

series273.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

134.0ms
(/ (* (* c a) 4) (* (* 2 a) (+ (- b) (sqrt (- (pow b 2) (* 4 (* a c)))))))
66.0ms
(sqrt (- (pow b 2) (* 4 (* a c))))
47.0ms
(+ (- b) (sqrt (- (pow b 2) (* 4 (* a c)))))
26.0ms
(- (pow b 2) (* 4 (* a c)))

simplify3.6s

Counts
31 → 70
Calls

31 calls. Slowest were:

860.0ms
(/ (* (* (* (* c a) 4) (* (* c a) 4)) (* (* c a) 4)) (* (* (* (* 2 a) (* 2 a)) (* 2 a)) (* (* (+ (- b) (sqrt (- (pow b 2) (* 4 (* a c))))) (+ (- b) (sqrt (- (pow b 2) (* 4 (* a c)))))) (+ (- b) (sqrt (- (pow b 2) (* 4 (* a c))))))))
759.0ms
(/ (* (* (* (* c a) 4) (* (* c a) 4)) (* (* c a) 4)) (* (* (* (* 2 a) (+ (- b) (sqrt (- (pow b 2) (* 4 (* a c)))))) (* (* 2 a) (+ (- b) (sqrt (- (pow b 2) (* 4 (* a c))))))) (* (* 2 a) (+ (- b) (sqrt (- (pow b 2) (* 4 (* a c))))))))
349.0ms
(sqrt (- (pow (pow b 2) 3) (pow (* 4 (* a c)) 3)))

prune829.0ms

Pruning

7 alts after pruning (4 fresh and 3 done)

Merged error: 5.0b

regimes334.0ms

Accuracy

85.3% (4.1b remaining)

Error of 9.7b against oracle of 5.7b and baseline of 33.3b

bsearch484.0ms

end0.0ms

sample5.0s

Algorithm
intervals