Average Error: 43.5 → 0.2
Time: 18.3s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[-2 \cdot \frac{c}{b + \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 43.5

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

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

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019016 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))

Details

Time bar (total: 17.5s)Debug log

sample191.0ms

Algorithm
intervals
Results
494×(pre true 80)
235×(body nan 80)
146×(body real 160)
63×(body real 80)
50×(body real 320)

simplify80.0ms

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

prune10.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 44.9b

localize35.0ms

Local error

Found 4 expressions with local error:

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

rewrite23.0ms

Algorithm
rewrite-expression-head
Rules
10×add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
sqrt-prod
add-exp-log
fma-neg
add-cbrt-cube
add-log-exp
log1p-expm1-u
pow1
expm1-log1p-u
associate-/l*
times-frac
associate-/l/
flip--
flip3--
div-inv
fma-udef
div-exp
div-sub
pow1/2
frac-2neg
sub-neg
associate-/r*
clear-num
rem-sqrt-square
cbrt-undiv
Counts
4 → 67
Calls
4 calls:
Slowest
11.0ms
(/ (- (sqrt (fma (* a -4) c (* b b))) b) (* 2 a))
10.0ms
(- (sqrt (fma (* a -4) c (* b b))) b)
1.0ms
(sqrt (fma (* a -4) c (* b b)))
0.0ms
(fma (* a -4) c (* b b))

series244.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
116.0ms
(/ (- (sqrt (fma (* a -4) c (* b b))) b) (* 2 a))
50.0ms
(- (sqrt (fma (* a -4) c (* b b))) b)
48.0ms
(sqrt (fma (* a -4) c (* b b)))
31.0ms
(fma (* a -4) c (* b b))

simplify1.4s

Counts
34 → 79
Calls
34 calls:
Slowest
621.0ms
(- (* (sqrt (fma (* a -4) c (* b b))) (sqrt (fma (* a -4) c (* b b)))) (* b b))
152.0ms
(- (pow (sqrt (fma (* a -4) c (* b b))) 3) (pow b 3))
88.0ms
(/ (* (* (- (sqrt (fma (* a -4) c (* b b))) b) (- (sqrt (fma (* a -4) c (* b b))) b)) (- (sqrt (fma (* a -4) c (* b b))) b)) (* (* (* 2 a) (* 2 a)) (* 2 a)))
65.0ms
(- (log (- (sqrt (fma (* a -4) c (* b b))) b)) (log (* 2 a)))
51.0ms
(- (pow b 2) (* 4 (* a c)))

prune676.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.4b

localize24.0ms

Local error

Found 4 expressions with local error:

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

rewrite34.0ms

Algorithm
rewrite-expression-head
Rules
11×add-exp-log
11×add-cbrt-cube
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
fma-def
pow1
add-log-exp
log1p-expm1-u
associate-*r/
expm1-log1p-u
flip-+
sqrt-prod
associate-*r*
flip3-+
cbrt-unprod
associate-/r/
prod-exp
div-exp
cbrt-undiv
associate-/l*
div-inv
fma-udef
*-commutative
pow-prod-down
associate-*l*
times-frac
distribute-lft-in
frac-2neg
associate-/r*
clear-num
+-commutative
distribute-rgt-in
Counts
4 → 70
Calls
4 calls:
Slowest
14.0ms
(* (* 2 a) (+ (sqrt (fma (* a -4) c (* b b))) b))
12.0ms
(/ (* (* a -4) c) (* (* 2 a) (+ (sqrt (fma (* a -4) c (* b b))) b)))
6.0ms
(+ (sqrt (fma (* a -4) c (* b b))) b)
0.0ms
(fma (* a -4) c (* b b))

series366.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
133.0ms
(/ (* (* a -4) c) (* (* 2 a) (+ (sqrt (fma (* a -4) c (* b b))) b)))
122.0ms
(* (* 2 a) (+ (sqrt (fma (* a -4) c (* b b))) b))
66.0ms
(+ (sqrt (fma (* a -4) c (* b b))) b)
45.0ms
(fma (* a -4) c (* b b))

simplify3.3s

Counts
37 → 82
Calls
37 calls:
Slowest
695.0ms
(- (log (* (* a -4) c)) (+ (log (* 2 a)) (log (+ (sqrt (fma (* a -4) c (* b b))) b))))
643.0ms
(/ (* (* (* (* a -4) c) (* (* a -4) c)) (* (* a -4) c)) (* (* (* (* 2 a) (* 2 a)) (* 2 a)) (* (* (+ (sqrt (fma (* a -4) c (* b b))) b) (+ (sqrt (fma (* a -4) c (* b b))) b)) (+ (sqrt (fma (* a -4) c (* b b))) b))))
544.0ms
(/ (* (* (* (* a -4) c) (* (* a -4) c)) (* (* a -4) c)) (* (* (* (* 2 a) (+ (sqrt (fma (* a -4) c (* b b))) b)) (* (* 2 a) (+ (sqrt (fma (* a -4) c (* b b))) b))) (* (* 2 a) (+ (sqrt (fma (* a -4) c (* b b))) b))))
441.0ms
(- (log (* (* a -4) c)) (log (* (* 2 a) (+ (sqrt (fma (* a -4) c (* b b))) b))))
224.0ms
(+ (* (sqrt (fma (* a -4) c (* b b))) (sqrt (fma (* a -4) c (* b b)))) (- (* b b) (* (sqrt (fma (* a -4) c (* b b))) b)))

prune775.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0b

localize8.0ms

Local error

Found 4 expressions with local error:

0.1b
(/ c (+ (sqrt (fma (* a -4) c (* b b))) b))
0.1b
(+ (sqrt (fma (* a -4) c (* b b))) b)
0.1b
(fma (* a -4) c (* b b))
0.1b
(sqrt (fma (* a -4) c (* b b)))

rewrite14.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
sqrt-prod
fma-def
add-log-exp
log1p-expm1-u
add-exp-log
add-cbrt-cube
pow1
expm1-log1p-u
associate-/r*
flip-+
associate-/r/
flip3-+
div-inv
fma-udef
pow1/2
frac-2neg
clear-num
rem-sqrt-square
+-commutative
Counts
4 → 59
Calls
4 calls:
Slowest
7.0ms
(+ (sqrt (fma (* a -4) c (* b b))) b)
5.0ms
(/ c (+ (sqrt (fma (* a -4) c (* b b))) b))
1.0ms
(sqrt (fma (* a -4) c (* b b)))
0.0ms
(fma (* a -4) c (* b b))

series304.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
116.0ms
(/ c (+ (sqrt (fma (* a -4) c (* b b))) b))
69.0ms
(+ (sqrt (fma (* a -4) c (* b b))) b)
66.0ms
(sqrt (fma (* a -4) c (* b b)))
53.0ms
(fma (* a -4) c (* b b))

simplify711.0ms

Counts
26 → 71
Calls
26 calls:
Slowest
315.0ms
(+ (* (sqrt (fma (* a -4) c (* b b))) (sqrt (fma (* a -4) c (* b b)))) (- (* b b) (* (sqrt (fma (* a -4) c (* b b))) b)))
52.0ms
(- (pow b 2) (* 4 (* a c)))
47.0ms
(- (pow b 2) (* 4 (* a c)))
44.0ms
(- (pow b 2) (* 4 (* a c)))
26.0ms
(* (cbrt (sqrt (fma (* a -4) c (* b b)))) (cbrt (sqrt (fma (* a -4) c (* b b)))))

prune801.0ms

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 0b

localize19.0ms

Local error

Found 4 expressions with local error:

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

rewrite1.0ms

Algorithm
rewrite-expression-head
Rules
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-log-exp
log1p-expm1-u
add-exp-log
add-cbrt-cube
pow1
expm1-log1p-u
fma-udef
associate-/r*
div-inv
frac-2neg
clear-num
Counts
4 → 45
Calls
4 calls:
Slowest
0.0ms
(/ c (fma (sqrt (sqrt (fma (* a -4) c (* b b)))) (sqrt (sqrt (fma (* a -4) c (* b b)))) b))
0.0ms
(fma (sqrt (sqrt (fma (* a -4) c (* b b)))) (sqrt (sqrt (fma (* a -4) c (* b b)))) b)
0.0ms
(fma (* a -4) c (* b b))
0.0ms
(fma (* a -4) c (* b b))

series684.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
315.0ms
(fma (sqrt (sqrt (fma (* a -4) c (* b b)))) (sqrt (sqrt (fma (* a -4) c (* b b)))) b)
288.0ms
(/ c (fma (sqrt (sqrt (fma (* a -4) c (* b b)))) (sqrt (sqrt (fma (* a -4) c (* b b)))) b))
50.0ms
(fma (* a -4) c (* b b))
31.0ms
(fma (* a -4) c (* b b))

simplify1.2s

Counts
15 → 57
Calls
15 calls:
Slowest
295.0ms
(+ (pow (exp (* 1/4 (- (log -4) (+ (log (/ 1 a)) (log (/ 1 c)))))) 2) b)
273.0ms
(- (/ c b) (+ (* 1/4 (/ (pow (exp (* 1/4 (- (log -4) (+ (log (/ -1 c)) (log (/ -1 a)))))) 4) (* a b))) (/ (* c (pow (exp (* 1/4 (- (log -4) (+ (log (/ -1 c)) (log (/ -1 a)))))) 2)) (pow b 2))))
167.0ms
(- (/ c b) (+ (/ (* (pow (exp (* 1/4 (- (log -4) (+ (log (/ 1 a)) (log (/ 1 c)))))) 2) c) (pow b 2)) (* 1/4 (/ (pow (exp (* 1/4 (- (log -4) (+ (log (/ 1 a)) (log (/ 1 c)))))) 4) (* a b)))))
109.0ms
(+ (pow (exp (* 1/4 (- (log -4) (+ (log (/ -1 c)) (log (/ -1 a)))))) 2) b)
49.0ms
(- (pow b 2) (* 4 (* a c)))

prune800.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0b

regimes220.0ms

Accuracy

0% (0.1b remaining)

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

bsearch2.0ms

end0.0ms

sample5.6s

Algorithm
intervals
Results
16370×(pre true 80)
8370×(body nan 80)
4762×(body real 160)
1851×(body real 80)
1387×(body real 320)