Average Error: 52.5 → 0.1
Time: 24.5s
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 52.5

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
  2. Simplified52.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--52.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/52.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.1

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

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

    \[\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, wide range"
  :pre (and (< 4.930380657631324e-32 a 2.028240960365167e+31) (< 4.930380657631324e-32 b 2.028240960365167e+31) (< 4.930380657631324e-32 c 2.028240960365167e+31))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))

Details

Time bar (total: 23.5s)Debug log

sample246.0ms

Algorithm
intervals
Results
520×(pre true 80)
264×(body nan 80)
126×(body real 320)
100×(body real 160)
21×(body real 80)
(body real 640)

simplify76.0ms

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

prune21.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 54.6b

localize411.0ms

Local error

Found 4 expressions with local error:

27.0b
(- (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.0b
(sqrt (fma (* a -4) c (* b b)))

rewrite39.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
21.0ms
(/ (- (sqrt (fma (* a -4) c (* b b))) b) (* 2 a))
13.0ms
(- (sqrt (fma (* a -4) c (* b b))) b)
2.0ms
(sqrt (fma (* a -4) c (* b b)))
0.0ms
(fma (* a -4) c (* b b))

series284.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
93.0ms
(/ (- (sqrt (fma (* a -4) c (* b b))) b) (* 2 a))
91.0ms
(- (sqrt (fma (* a -4) c (* b b))) b)
59.0ms
(sqrt (fma (* a -4) c (* b b)))
40.0ms
(fma (* a -4) c (* b b))

simplify1.5s

Counts
34 → 79
Calls
34 calls:
Slowest
646.0ms
(- (* (sqrt (fma (* a -4) c (* b b))) (sqrt (fma (* a -4) c (* b b)))) (* b b))
120.0ms
(- (pow (sqrt (fma (* a -4) c (* b b))) 3) (pow b 3))
119.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)))
76.0ms
(- (log (- (sqrt (fma (* a -4) c (* b b))) b)) (log (* 2 a)))
41.0ms
(/ (* (cbrt (- (sqrt (fma (* a -4) c (* b b))) b)) (cbrt (- (sqrt (fma (* a -4) c (* b b))) b))) 2)

prune663.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.4b

localize23.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))

rewrite37.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
19.0ms
(/ (* (* a -4) c) (* (* 2 a) (+ (sqrt (fma (* a -4) c (* b b))) b)))
13.0ms
(* (* 2 a) (+ (sqrt (fma (* a -4) c (* b b))) b))
4.0ms
(+ (sqrt (fma (* a -4) c (* b b))) b)
0.0ms
(fma (* a -4) c (* b b))

series291.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
96.0ms
(/ (* (* a -4) c) (* (* 2 a) (+ (sqrt (fma (* a -4) c (* b b))) b)))
85.0ms
(* (* 2 a) (+ (sqrt (fma (* a -4) c (* b b))) b))
78.0ms
(+ (sqrt (fma (* a -4) c (* b b))) b)
33.0ms
(fma (* a -4) c (* b b))

simplify3.4s

Counts
37 → 82
Calls
37 calls:
Slowest
644.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))))
605.0ms
(- (log (* (* a -4) c)) (+ (log (* 2 a)) (log (+ (sqrt (fma (* a -4) c (* b b))) b))))
588.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))))
391.0ms
(- (log (* (* a -4) c)) (log (* (* 2 a) (+ (sqrt (fma (* a -4) c (* b b))) b))))
269.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)))

prune934.0ms

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 0.0b

localize12.0ms

Local error

Found 4 expressions with local error:

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

rewrite13.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
6.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))

series298.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
137.0ms
(/ c (+ (sqrt (fma (* a -4) c (* b b))) b))
67.0ms
(sqrt (fma (* a -4) c (* b b)))
47.0ms
(fma (* a -4) c (* b b))
47.0ms
(+ (sqrt (fma (* a -4) c (* b b))) b)

simplify581.0ms

Counts
26 → 71
Calls
26 calls:
Slowest
233.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)))
31.0ms
(- (pow b 2) (* 4 (* a c)))
29.0ms
(* (cbrt (sqrt (fma (* a -4) c (* b b)))) (cbrt (sqrt (fma (* a -4) c (* b b)))))
28.0ms
(sqrt (* (cbrt (fma (* a -4) c (* b b))) (cbrt (fma (* a -4) c (* b b)))))
28.0ms
(sqrt (* (cbrt (fma (* a -4) c (* b b))) (cbrt (fma (* a -4) c (* b b)))))

prune718.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0b

localize33.0ms

Local error

Found 4 expressions with local error:

0.5b
(* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b)))
0.5b
(cbrt (* (* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b))) (fma (* a -4) c (* b b))))
0.4b
(* (* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b))) (fma (* a -4) c (* b b)))
0.1b
(+ (sqrt (cbrt (* (* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b))) (fma (* a -4) c (* b b))))) b)

rewrite59.0ms

Algorithm
rewrite-expression-head
Rules
23×pow1
11×add-exp-log
11×add-cbrt-cube
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
fma-def
pow-prod-up
associate-*r*
pow-plus
add-log-exp
log1p-expm1-u
fma-udef
cbrt-unprod
sqrt-prod
prod-exp
pow-prod-down
associate-*l*
expm1-log1p-u
pow2
*-commutative
pow3
distribute-lft-in
distribute-rgt-in
cbrt-prod
flip-+
rem-cbrt-cube
pow1/3
flip3-+
+-commutative
Counts
4 → 84
Calls
4 calls:
Slowest
19.0ms
(* (* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b))) (fma (* a -4) c (* b b)))
13.0ms
(* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b)))
13.0ms
(+ (sqrt (cbrt (* (* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b))) (fma (* a -4) c (* b b))))) b)
12.0ms
(cbrt (* (* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b))) (fma (* a -4) c (* b b))))

series254.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
99.0ms
(* (* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b))) (fma (* a -4) c (* b b)))
69.0ms
(+ (sqrt (cbrt (* (* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b))) (fma (* a -4) c (* b b))))) b)
55.0ms
(* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b)))
31.0ms
(cbrt (* (* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b))) (fma (* a -4) c (* b b))))

simplify5.6s

Counts
55 → 96
Calls
55 calls:
Slowest
1.1s
(* (* (* (* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b))) (fma (* a -4) c (* b b))) (* (* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b))) (fma (* a -4) c (* b b)))) (* (* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b))) (fma (* a -4) c (* b b))))
720.0ms
(* (* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b))) (* b b))
508.0ms
(* (* (* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b))) (fma (* a -4) c (* b b))) (* (* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b))) (fma (* a -4) c (* b b))))
259.0ms
(- (+ (pow b 6) (* 48 (* (pow a 2) (* (pow b 2) (pow c 2))))) (* 12 (* a (* (pow b 4) c))))
255.0ms
(* (fma (* a -4) c (* b b)) (fma (* a -4) c (* b b)))

prune1.3s

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0b

regimes207.0ms

Accuracy

0% (0.1b remaining)

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

bsearch2.0ms

end0.0ms

sample6.5s

Algorithm
intervals
Results
15955×(pre true 80)
7953×(body nan 80)
3652×(body real 320)
2910×(body real 160)
933×(body real 80)
507×(body real 640)