Average Error: 28.5 → 0.3
Time: 1.2m
Precision: 64
Internal Precision: 128
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\frac{2 \cdot c}{\left(-b\right) - \sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*}}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 28.5

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{2 \cdot c}}{\left(-b\right) - \sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*}}\]
  10. Final simplification0.3

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

Reproduce

herbie shell --seed 2019010 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))

Details

Time bar (total: 1.2m)Debug log

sample245.0ms

Algorithm
intervals

simplify94.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
94.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))

prune10.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 27.5b

localize37.0ms

Local error

Found 4 expressions with local error:

27.1b
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
0.3b
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))
0.3b
(- (* b b) (* (* 4 a) c))
0.1b
(sqrt (- (* b b) (* (* 4 a) c)))

rewrite36.0ms

Algorithm
rewrite-expression-head
Rules
14×*-un-lft-identity
add-sqr-sqrt
add-log-exp
add-cube-cbrt
add-exp-log
add-cbrt-cube
associate-/l*
log1p-expm1-u
times-frac
fma-def
pow1
expm1-log1p-u
distribute-lft-out
sqrt-prod
associate-/l/
flip--
flip-+
associate-+l-
sqrt-div
flip3--
flip3-+
neg-sub0
div-inv
prod-diff
div-exp
div-sub
diff-log
fma-neg
pow1/2
frac-2neg
sub-neg
sum-log
neg-mul-1
associate-/r*
clear-num
rem-sqrt-square
+-commutative
cbrt-undiv
Counts
4 → 77
Calls
4 calls:
Slowest
23.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))
7.0ms
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
3.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
2.0ms
(- (* b b) (* (* 4 a) c))

series254.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
82.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))
69.0ms
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
59.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
43.0ms
(- (* b b) (* (* 4 a) c))

simplify2.6s

Counts
40 → 89
Calls
40 calls:
Slowest
402.0ms
(- (* (- b) (- b)) (* (sqrt (- (* b b) (* (* 4 a) c))) (sqrt (- (* b b) (* (* 4 a) c)))))
380.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
221.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 4 a) c) (* (* 4 a) c))))
163.0ms
(- b (* 2 (/ (* a c) b)))
155.0ms
(+ (pow (- b) 3) (pow (sqrt (- (* b b) (* (* 4 a) c))) 3))

prune1.0s

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 0.3b

localize17.0ms

Local error

Found 4 expressions with local error:

0.4b
(/ (* 4 (* c a)) (* (* 2 a) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))))
0.3b
(- (* b b) (* (* 4 a) c))
0.2b
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
0.2b
(* (* 2 a) (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))))

rewrite47.0ms

Algorithm
rewrite-expression-head
Rules
73×prod-diff
56×add-sqr-sqrt
52×*-un-lft-identity
48×add-cube-cbrt
38×sqrt-prod
26×distribute-lft-in
26×distribute-rgt-in
19×neg-mul-1
11×add-exp-log
11×add-cbrt-cube
add-log-exp
associate-*r*
pow1
fma-neg
difference-of-squares
flip--
log1p-expm1-u
associate-*r/
flip3--
sub-neg
expm1-log1p-u
distribute-lft-out--
cbrt-unprod
associate-/r/
prod-exp
div-exp
diff-log
cbrt-undiv
associate-/l*
div-inv
*-commutative
pow-prod-down
associate-*l*
times-frac
frac-2neg
associate-/r*
clear-num
neg-sub0
associate--l-
Counts
4 → 157
Calls
4 calls:
Slowest
20.0ms
(/ (* 4 (* c a)) (* (* 2 a) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))))
15.0ms
(* (* 2 a) (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))))
7.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
2.0ms
(- (* b b) (* (* 4 a) c))

series330.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
154.0ms
(/ (* 4 (* c a)) (* (* 2 a) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))))
74.0ms
(* (* 2 a) (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))))
57.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
45.0ms
(- (* b b) (* (* 4 a) c))

simplify20.2s

Counts
143 → 169
Calls
143 calls:
Slowest
962.0ms
(/ (* (* (* 4 (* c a)) (* 4 (* c a))) (* 4 (* c a))) (* (* (* (* 2 a) (* 2 a)) (* 2 a)) (* (* (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))) (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))))))
735.0ms
(/ (* (* (* 4 (* c a)) (* 4 (* c a))) (* 4 (* c a))) (* (* (* (* 2 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)))))))
643.0ms
(* (fma (- (sqrt (- (* b b) (* (* 4 a) c)))) 1 (* (sqrt (- (* b b) (* (* 4 a) c))) 1)) (* 2 a))
433.0ms
(* (* 2 a) (fma (- (cbrt (sqrt (- (* b b) (* (* 4 a) c))))) (* (cbrt (sqrt (- (* b b) (* (* 4 a) c)))) (cbrt (sqrt (- (* b b) (* (* 4 a) c))))) (* (cbrt (sqrt (- (* b b) (* (* 4 a) c)))) (* (cbrt (sqrt (- (* b b) (* (* 4 a) c)))) (cbrt (sqrt (- (* b b) (* (* 4 a) c))))))))
419.0ms
(+ (* (- b) (- b)) (+ (* (sqrt (- (* b b) (* (* 4 a) c))) (sqrt (- (* b b) (* (* 4 a) c)))) (* (- b) (sqrt (- (* b b) (* (* 4 a) c))))))

prune2.0s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 0.0b

localize25.0ms

Local error

Found 4 expressions with local error:

0.3b
(fma (* a -4) c (* b b))
0.2b
(- (- b) (sqrt (fma (* a -4) c (* b b))))
0.2b
(/ (/ (* 4 (* c a)) (* 2 a)) (- (- b) (sqrt (fma (* a -4) c (* b b)))))
0.1b
(/ (* 4 (* c a)) (* 2 a))

rewrite41.0ms

Algorithm
rewrite-expression-head
Rules
60×add-sqr-sqrt
46×*-un-lft-identity
38×times-frac
32×add-cube-cbrt
24×prod-diff
19×sqrt-prod
14×difference-of-squares
11×add-exp-log
11×add-cbrt-cube
div-inv
distribute-lft-out--
neg-mul-1
associate-/r*
add-log-exp
associate-/l*
log1p-expm1-u
div-exp
fma-neg
cbrt-undiv
pow1
expm1-log1p-u
flip--
associate-/r/
flip3--
frac-2neg
clear-num
associate-/l/
fma-udef
diff-log
sub-neg
neg-sub0
associate--l-
Counts
4 → 133
Calls
4 calls:
Slowest
20.0ms
(/ (/ (* 4 (* c a)) (* 2 a)) (- (- b) (sqrt (fma (* a -4) c (* b b)))))
9.0ms
(- (- b) (sqrt (fma (* a -4) c (* b b))))
8.0ms
(/ (* 4 (* c a)) (* 2 a))
0.0ms
(fma (* a -4) c (* b b))

series234.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
127.0ms
(/ (/ (* 4 (* c a)) (* 2 a)) (- (- b) (sqrt (fma (* a -4) c (* b b)))))
69.0ms
(- (- b) (sqrt (fma (* a -4) c (* b b))))
29.0ms
(fma (* a -4) c (* b b))
8.0ms
(/ (* 4 (* c a)) (* 2 a))

simplify34.4s

Counts
149 → 145
Calls
149 calls:
Slowest
1.2s
(/ (* (cbrt (/ (* 4 (* c a)) (* 2 a))) (cbrt (/ (* 4 (* c a)) (* 2 a)))) (+ (sqrt (- b)) (sqrt (sqrt (fma (* a -4) c (* b b))))))
1.1s
(/ (/ (* (* (* 4 (* c a)) (* 4 (* c a))) (* 4 (* c a))) (* (* (* 2 a) (* 2 a)) (* 2 a))) (* (* (- (- b) (sqrt (fma (* a -4) c (* b b)))) (- (- b) (sqrt (fma (* a -4) c (* b b))))) (- (- b) (sqrt (fma (* a -4) c (* b b))))))
1.1s
(/ (* (cbrt (/ (* 4 (* c a)) (* 2 a))) (cbrt (/ (* 4 (* c a)) (* 2 a)))) (+ (sqrt (- b)) (sqrt (sqrt (fma (* a -4) c (* b b))))))
1.1s
(sqrt (/ (* 4 (* c a)) (* 2 a)))
985.0ms
(* (cbrt (/ (* 4 (* c a)) (* 2 a))) (cbrt (/ (* 4 (* c a)) (* 2 a))))

prune1.6s

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0b

localize6.0ms

Local error

Found 4 expressions with local error:

0.3b
(fma (* a -4) c (* b b))
0.2b
(- (- b) (sqrt (fma (* a -4) c (* b b))))
0.2b
(/ (* 2 c) (- (- b) (sqrt (fma (* a -4) c (* b b)))))
0.1b
(sqrt (fma (* a -4) c (* b b)))

rewrite25.0ms

Algorithm
rewrite-expression-head
Rules
35×add-sqr-sqrt
28×*-un-lft-identity
24×prod-diff
22×add-cube-cbrt
18×sqrt-prod
neg-mul-1
difference-of-squares
add-log-exp
add-exp-log
add-cbrt-cube
times-frac
associate-/r*
log1p-expm1-u
fma-neg
pow1
expm1-log1p-u
distribute-lft-out--
flip--
associate-/r/
flip3--
associate-/l*
div-inv
fma-udef
div-exp
diff-log
pow1/2
frac-2neg
sub-neg
clear-num
rem-sqrt-square
cbrt-undiv
neg-sub0
associate--l-
Counts
4 → 99
Calls
4 calls:
Slowest
15.0ms
(/ (* 2 c) (- (- b) (sqrt (fma (* a -4) c (* b b)))))
6.0ms
(- (- b) (sqrt (fma (* a -4) c (* b b))))
2.0ms
(sqrt (fma (* a -4) c (* b b)))
0.0ms
(fma (* a -4) c (* b b))

series301.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
156.0ms
(/ (* 2 c) (- (- b) (sqrt (fma (* a -4) c (* b b)))))
53.0ms
(fma (* a -4) c (* b b))
49.0ms
(sqrt (fma (* a -4) c (* b b)))
43.0ms
(- (- b) (sqrt (fma (* a -4) c (* b b))))

simplify3.3s

Counts
94 → 111
Calls
94 calls:
Slowest
383.0ms
(+ (* (- b) (- b)) (+ (* (sqrt (fma (* a -4) c (* b b))) (sqrt (fma (* a -4) c (* b b)))) (* (- b) (sqrt (fma (* a -4) c (* b b))))))
97.0ms
(/ (* (* (* 2 c) (* 2 c)) (* 2 c)) (* (* (- (- b) (sqrt (fma (* a -4) c (* b b)))) (- (- b) (sqrt (fma (* a -4) c (* b b))))) (- (- b) (sqrt (fma (* a -4) c (* b b))))))
78.0ms
(fma 1 (- b) (- (* (sqrt (fma (* a -4) c (* b b))) (sqrt 1))))
76.0ms
(fma 1 (- b) (- (* (sqrt (fma (* a -4) c (* b b))) 1)))
66.0ms
(fma (* (cbrt (- b)) (cbrt (- b))) (cbrt (- b)) (- (* (sqrt (cbrt (fma (* a -4) c (* b b)))) (sqrt (* (cbrt (fma (* a -4) c (* b b))) (cbrt (fma (* a -4) c (* b b))))))))

prune1.1s

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 0b

regimes194.0ms

Accuracy

0% (0.3b remaining)

Error of 0.3b against oracle of 0.0b and baseline of 0.3b

bsearch1.0ms

end0.0ms

sample4.8s

Algorithm
intervals