Average Error: 33.1 → 6.7
Time: 20.4s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -4.1146996886759634 \cdot 10^{+123}:\\ \;\;\;\;(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*\\ \mathbf{elif}\;b_2 \le 5.770837317334599 \cdot 10^{-298}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 2.1684855184037787 \cdot 10^{+58}:\\ \;\;\;\;\frac{-c}{(\left(\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}}\right) \cdot \left(\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}}\right) + b_2)_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b_2 + (\left(a \cdot \frac{c}{b_2}\right) \cdot \frac{-1}{2} + b_2)_*}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -4.1146996886759634e+123

    1. Initial program 49.0

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified49.0

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around -inf 3.2

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}}\]
    4. Simplified3.2

      \[\leadsto \color{blue}{(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*}\]

    if -4.1146996886759634e+123 < b_2 < 5.770837317334599e-298

    1. Initial program 9.1

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified9.1

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-sub9.1

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} - \frac{b_2}{a}}\]

    if 5.770837317334599e-298 < b_2 < 2.1684855184037787e+58

    1. Initial program 30.0

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified30.0

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-inv30.1

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Using strategy rm
    6. Applied flip--30.2

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}} \cdot \frac{1}{a}\]
    7. Applied associate-*l/30.3

      \[\leadsto \color{blue}{\frac{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2\right) \cdot \frac{1}{a}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}\]
    8. Simplified16.4

      \[\leadsto \frac{\color{blue}{\frac{(a \cdot \left(-c\right) + 0)_*}{a}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    9. Taylor expanded around -inf 9.0

      \[\leadsto \frac{\color{blue}{-1 \cdot c}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    10. Simplified9.0

      \[\leadsto \frac{\color{blue}{-c}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    11. Using strategy rm
    12. Applied add-sqr-sqrt9.0

      \[\leadsto \frac{-c}{\sqrt{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}} + b_2}\]
    13. Applied sqrt-prod9.2

      \[\leadsto \frac{-c}{\color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}} + b_2}\]
    14. Applied fma-def9.2

      \[\leadsto \frac{-c}{\color{blue}{(\left(\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}\right) \cdot \left(\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}\right) + b_2)_*}}\]

    if 2.1684855184037787e+58 < b_2

    1. Initial program 56.4

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-inv56.4

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Using strategy rm
    6. Applied flip--56.4

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}} \cdot \frac{1}{a}\]
    7. Applied associate-*l/56.4

      \[\leadsto \color{blue}{\frac{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2\right) \cdot \frac{1}{a}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}\]
    8. Simplified28.0

      \[\leadsto \frac{\color{blue}{\frac{(a \cdot \left(-c\right) + 0)_*}{a}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    9. Taylor expanded around -inf 26.6

      \[\leadsto \frac{\color{blue}{-1 \cdot c}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    10. Simplified26.6

      \[\leadsto \frac{\color{blue}{-c}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    11. Taylor expanded around inf 5.9

      \[\leadsto \frac{-c}{\color{blue}{\left(b_2 - \frac{1}{2} \cdot \frac{a \cdot c}{b_2}\right)} + b_2}\]
    12. Simplified3.3

      \[\leadsto \frac{-c}{\color{blue}{(\left(\frac{c}{b_2} \cdot a\right) \cdot \frac{-1}{2} + b_2)_*} + b_2}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -4.1146996886759634 \cdot 10^{+123}:\\ \;\;\;\;(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*\\ \mathbf{elif}\;b_2 \le 5.770837317334599 \cdot 10^{-298}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 2.1684855184037787 \cdot 10^{+58}:\\ \;\;\;\;\frac{-c}{(\left(\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}}\right) \cdot \left(\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}}\right) + b_2)_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b_2 + (\left(a \cdot \frac{c}{b_2}\right) \cdot \frac{-1}{2} + b_2)_*}\\ \end{array}\]

Reproduce

herbie shell --seed 2019010 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))

Details

Time bar (total: 19.4s)Debug log

sample229.0ms

Algorithm
intervals

simplify56.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
55.0ms
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)

prune20.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 32.9b

localize19.0ms

Local error

Found 4 expressions with local error:

22.0b
(sqrt (- (* b_2 b_2) (* a c)))
1.7b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.2b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)

rewrite51.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
fma-neg
add-log-exp
sqrt-prod
flip--
log1p-expm1-u
add-exp-log
add-cbrt-cube
flip3--
pow1
expm1-log1p-u
associate-/l*
associate-/l/
sqrt-div
sub-neg
div-inv
prod-diff
div-sub
diff-log
pow1/2
frac-2neg
clear-num
rem-sqrt-square
Counts
4 → 69
Calls
4 calls:
Slowest
30.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
12.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
4.0ms
(sqrt (- (* b_2 b_2) (* a c)))
2.0ms
(- (* b_2 b_2) (* a c))

series178.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
52.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
49.0ms
(sqrt (- (* b_2 b_2) (* a c)))
41.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
36.0ms
(- (* b_2 b_2) (* a c))

simplify2.0s

Counts
31 → 81
Calls
31 calls:
Slowest
522.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))
469.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
370.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
132.0ms
(- (pow (sqrt (- (* b_2 b_2) (* a c))) 3) (pow b_2 3))
90.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune679.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 6.3b

localize8.0ms

Local error

Found 4 expressions with local error:

22.0b
(sqrt (- (* b_2 b_2) (* a c)))
1.7b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.2b
(- (* b_2 b_2) (* a c))
0.2b
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))

rewrite48.0ms

Algorithm
rewrite-expression-head
Rules
10×add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
fma-neg
add-log-exp
sqrt-prod
add-exp-log
add-cbrt-cube
pow1
flip--
flip3--
log1p-expm1-u
associate-*r*
expm1-log1p-u
associate-*l*
associate-*l/
sqrt-div
sub-neg
frac-times
div-inv
cbrt-unprod
*-commutative
un-div-inv
associate-*r/
prod-exp
pow-prod-down
prod-diff
diff-log
pow1/2
rem-sqrt-square
Counts
4 → 77
Calls
4 calls:
Slowest
29.0ms
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))
13.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
3.0ms
(sqrt (- (* b_2 b_2) (* a c)))
2.0ms
(- (* b_2 b_2) (* a c))

series211.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
83.0ms
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))
61.0ms
(sqrt (- (* b_2 b_2) (* a c)))
46.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
21.0ms
(- (* b_2 b_2) (* a c))

simplify3.7s

Counts
41 → 89
Calls
41 calls:
Slowest
622.0ms
(* (- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2)) 1)
471.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
456.0ms
(* (* (* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (- (sqrt (- (* b_2 b_2) (* a c))) b_2)) (- (sqrt (- (* b_2 b_2) (* a c))) b_2)) (* (* (/ 1 a) (/ 1 a)) (/ 1 a)))
374.0ms
(* (- (pow (sqrt (- (* b_2 b_2) (* a c))) 3) (pow b_2 3)) (/ 1 a))
317.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))

prune882.0ms

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 6.2b

localize28.0ms

Local error

Found 4 expressions with local error:

22.0b
(sqrt (- (* b_2 b_2) (* a c)))
14.3b
(/ (fma a (- c) 0) a)
0.4b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.2b
(- (* b_2 b_2) (* a c))

rewrite23.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
add-log-exp
sqrt-prod
fma-def
log1p-expm1-u
add-exp-log
add-cbrt-cube
pow1
expm1-log1p-u
associate-/l*
flip--
sqrt-div
flip3--
div-inv
flip-+
prod-diff
diff-log
fma-neg
pow1/2
flip3-+
frac-2neg
sub-neg
clear-num
rem-sqrt-square
+-commutative
Counts
4 → 65
Calls
4 calls:
Slowest
12.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
6.0ms
(sqrt (- (* b_2 b_2) (* a c)))
3.0ms
(/ (fma a (- c) 0) a)
2.0ms
(- (* b_2 b_2) (* a c))

series134.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
46.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
45.0ms
(sqrt (- (* b_2 b_2) (* a c)))
22.0ms
(/ (fma a (- c) 0) a)
21.0ms
(- (* b_2 b_2) (* a c))

simplify1.3s

Counts
28 → 77
Calls
28 calls:
Slowest
492.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
249.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
156.0ms
(- (* 2 b_2) (* 1/2 (/ (* a c) b_2)))
106.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
77.0ms
(- (* 1/2 (/ (* a c) b_2)) b_2)

prune817.0ms

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 6.2b

localize3.0ms

Local error

Found 4 expressions with local error:

22.0b
(sqrt (- (* b_2 b_2) (* a c)))
0.4b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.2b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))

rewrite33.0ms

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

series272.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
129.0ms
(/ (- c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))
62.0ms
(sqrt (- (* b_2 b_2) (* a c)))
52.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
30.0ms
(- (* b_2 b_2) (* a c))

simplify2.6s

Counts
61 → 99
Calls
61 calls:
Slowest
432.0ms
(/ (* (* (- c) (- c)) (- c)) (* (* (+ (sqrt (- (* b_2 b_2) (* a c))) b_2) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
410.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
371.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
289.0ms
(+ (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (- (* b_2 b_2) (* (sqrt (- (* b_2 b_2) (* a c))) b_2)))
128.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune1.0s

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 6.2b

regimes341.0ms

Accuracy

94.8% (1.3b remaining)

Error of 6.7b against oracle of 5.4b and baseline of 29.4b

bsearch442.0ms

end0.0ms

sample4.3s

Algorithm
intervals