Average Error: 33.4 → 6.7
Time: 22.2s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -6.341219225938887 \cdot 10^{+106}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 3.45159933628946 \cdot 10^{-306}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}{a \cdot 2}\\ \mathbf{elif}\;b \le 2.408724732699167 \cdot 10^{+98}:\\ \;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \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

Derivation

  1. Split input into 4 regimes
  2. if b < -6.341219225938887e+106

    1. Initial program 45.4

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

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

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

    if -6.341219225938887e+106 < b < 3.45159933628946e-306

    1. Initial program 8.9

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

      \[\leadsto \color{blue}{\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2 \cdot a}}\]
    4. Using strategy rm
    5. Applied un-div-inv8.9

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

    if 3.45159933628946e-306 < b < 2.408724732699167e+98

    1. Initial program 32.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 div-inv32.5

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

      \[\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(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}} \cdot \frac{1}{2 \cdot a}\]
    6. Applied associate-*l/32.7

      \[\leadsto \color{blue}{\frac{\left(\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}\right) \cdot \frac{1}{2 \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\]
    7. Simplified16.4

      \[\leadsto \frac{\color{blue}{\left(\left(c \cdot a\right) \cdot 4\right) \cdot \frac{\frac{1}{2}}{a}}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\]
    8. Taylor expanded around 0 9.1

      \[\leadsto \frac{\color{blue}{2 \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\]
    9. Using strategy rm
    10. Applied *-un-lft-identity9.1

      \[\leadsto \frac{2 \cdot c}{\color{blue}{1 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}\]
    11. Applied associate-/r*9.1

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

    if 2.408724732699167e+98 < b

    1. Initial program 58.7

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    5. Simplified2.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -6.341219225938887 \cdot 10^{+106}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 3.45159933628946 \cdot 10^{-306}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}{a \cdot 2}\\ \mathbf{elif}\;b \le 2.408724732699167 \cdot 10^{+98}:\\ \;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019008 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))

Details

Time bar (total: 21.2s)Debug log

sample151.0ms

Algorithm
intervals

simplify75.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune17.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 34.5b

localize23.0ms

Local error

Found 4 expressions with local error:

23.3b
(sqrt (- (* b b) (* (* 4 a) c)))
1.0b
(- (* b b) (* (* 4 a) c))
0.9b
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
0.1b
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))

rewrite59.0ms

Algorithm
rewrite-expression-head
Counts
4 → 63
Calls

4 calls. Slowest were:

44.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))
9.0ms
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
2.0ms
(- (* b b) (* (* 4 a) c))

series269.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

93.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))
72.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
61.0ms
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
42.0ms
(- (* b b) (* (* 4 a) c))

simplify2.4s

Counts
36 → 75
Calls

36 calls. Slowest were:

417.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
260.0ms
(+ (pow (- b) 3) (pow (sqrt (- (* b b) (* (* 4 a) c))) 3))
233.0ms
(- (* (- b) (- b)) (* (sqrt (- (* b b) (* (* 4 a) c))) (sqrt (- (* b b) (* (* 4 a) c)))))

prune972.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 6.9b

localize15.0ms

Local error

Found 4 expressions with local error:

23.3b
(sqrt (- (* b b) (* (* 4 a) c)))
1.0b
(- (* b b) (* (* 4 a) c))
0.9b
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
0.2b
(* (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (/ 1 (* 2 a)))

rewrite35.0ms

Algorithm
rewrite-expression-head
Counts
4 → 65
Calls

4 calls. Slowest were:

15.0ms
(* (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (/ 1 (* 2 a)))
11.0ms
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
4.0ms
(- (* b b) (* (* 4 a) c))

series255.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

99.0ms
(* (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (/ 1 (* 2 a)))
59.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
52.0ms
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
45.0ms
(- (* b b) (* (* 4 a) c))

simplify3.4s

Counts
39 → 77
Calls

39 calls. Slowest were:

384.0ms
(* (- (* (- b) (- b)) (* (sqrt (- (* b b) (* (* 4 a) c))) (sqrt (- (* b b) (* (* 4 a) c))))) (/ 1 (* 2 a)))
374.0ms
(* (- (* (- b) (- b)) (* (sqrt (- (* b b) (* (* 4 a) c))) (sqrt (- (* b b) (* (* 4 a) c))))) 1)
363.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))

prune882.0ms

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 6.9b

localize34.0ms

Local error

Found 4 expressions with local error:

23.3b
(sqrt (- (* b b) (* (* 4 a) c)))
15.2b
(* (* (* c a) 4) (/ 1/2 a))
1.0b
(- (* b b) (* (* 4 a) c))
0.8b
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))

rewrite34.0ms

Algorithm
rewrite-expression-head
Counts
4 → 59
Calls

4 calls. Slowest were:

13.0ms
(* (* (* c a) 4) (/ 1/2 a))
11.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
4.0ms
(- (* b b) (* (* 4 a) c))

series188.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

76.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
60.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
44.0ms
(- (* b b) (* (* 4 a) c))
8.0ms
(* (* (* c a) 4) (/ 1/2 a))

simplify2.4s

Counts
33 → 71
Calls

33 calls. Slowest were:

425.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
386.0ms
(+ (log (* (* c a) 4)) (log (/ 1/2 a)))
352.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))

prune941.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 6.9b

localize6.0ms

Local error

Found 4 expressions with local error:

23.3b
(sqrt (- (* b b) (* (* 4 a) c)))
1.0b
(- (* b b) (* (* 4 a) c))
0.8b
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
0.1b
(/ (* 2 c) (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))))

rewrite23.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

10.0ms
(/ (* 2 c) (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))))
8.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
2.0ms
(- (* b b) (* (* 4 a) c))

series326.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

165.0ms
(/ (* 2 c) (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))))
77.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
50.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
34.0ms
(- (* b b) (* (* 4 a) c))

simplify2.6s

Counts
47 → 81
Calls

47 calls. Slowest were:

424.0ms
(+ (* (- b) (- b)) (+ (* (sqrt (- (* b b) (* (* 4 a) c))) (sqrt (- (* b b) (* (* 4 a) c)))) (* (- b) (sqrt (- (* b b) (* (* 4 a) c))))))
399.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
164.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 4 a) c) (* (* 4 a) c))))

prune802.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 6.9b

regimes383.0ms

Accuracy

95.3% (1.1b remaining)

Error of 6.7b against oracle of 5.6b and baseline of 28.9b

bsearch698.0ms

end0.0ms

sample4.2s

Algorithm
intervals