Average Error: 19.5 → 8.3
Time: 25.0s
Precision: 64
Internal Precision: 128
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -2.0310547919335672 \cdot 10^{+166}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}\\ \end{array}\\ \mathbf{elif}\;b \le 4.258162565501791 \cdot 10^{+108}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \left|\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right|}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{c}}\\ \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 3 regimes
  2. if b < -2.0310547919335672e+166

    1. Initial program 37.3

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Taylor expanded around -inf 7.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\color{blue}{\frac{2 \cdot c}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}\\ \end{array}\]

    if -2.0310547919335672e+166 < b < 4.258162565501791e+108

    1. Initial program 9.4

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt9.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\color{blue}{\left(\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    4. Applied sqrt-prod9.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \color{blue}{\sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    5. Simplified9.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \color{blue}{\left|\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right|} \cdot \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]

    if 4.258162565501791e+108 < b

    1. Initial program 46.4

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Taylor expanded around inf 10.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{a \cdot c}{b}\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    3. Taylor expanded around 0 3.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\color{blue}{\frac{c}{b} - \frac{b}{a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    4. Using strategy rm
    5. Applied associate-/l*3.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{c}}\\ \end{array}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification8.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.0310547919335672 \cdot 10^{+166}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}\\ \end{array}\\ \mathbf{elif}\;b \le 4.258162565501791 \cdot 10^{+108}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \left|\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right|}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{c}}\\ \end{array}\]

Reproduce

herbie shell --seed 2018365 
(FPCore (a b c)
  :name "jeff quadratic root 1"
  (if (>= b 0) (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ (* 2 c) (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))))))

Details

Time bar (total: 20.6s)Debug log

start91.0ms

Algorithm
intervals

setup138.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 18.8b

localize138.0ms

Local error

Found 4 expressions with local error:

24.1b
(sqrt (- (* b b) (* (* 4 a) c)))
24.1b
(sqrt (- (* b b) (* (* 4 a) c)))
1.2b
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
1.2b
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))

rewrite15.0ms

Algorithm
rewrite-expression-head
Counts
4 → 57
Calls

4 calls. Slowest were:

5.0ms
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
5.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
2.0ms
(sqrt (- (* b b) (* (* 4 a) c)))

series225.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

65.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
64.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
52.0ms
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
44.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))

simplify2.4s

Counts
32 → 69
Calls

32 calls. Slowest were:

404.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
391.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
169.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 4 a) c) (* (* 4 a) c))))

prune1.2s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 7.5b

localize169.0ms

Local error

Found 4 expressions with local error:

24.1b
(sqrt (- (* b b) (* (* 4 a) c)))
4.8b
(/ (* a c) b)
3.5b
(/ (- (- b) (- b (* 2 (/ (* a c) b)))) (* 2 a))
1.2b
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))

rewrite42.0ms

Algorithm
rewrite-expression-head
Counts
4 → 64
Calls

4 calls. Slowest were:

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

series182.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

77.0ms
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
45.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
44.0ms
(/ (- (- b) (- b (* 2 (/ (* a c) b)))) (* 2 a))
15.0ms
(/ (* a c) b)

simplify4.8s

Counts
38 → 76
Calls

38 calls. Slowest were:

669.0ms
(* (cbrt (- (- b) (- b (* 2 (/ (* a c) b))))) (cbrt (- (- b) (- b (* 2 (/ (* a c) b))))))
473.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
300.0ms
(/ (sqrt (- (- b) (- b (* 2 (/ (* a c) b))))) a)

prune1.6s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 6.2b

localize138.0ms

Local error

Found 4 expressions with local error:

24.1b
(sqrt (- (* b b) (* (* 4 a) c)))
1.2b
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
0.8b
(- (* b b) (* (* 4 a) c))
0.1b
(/ (* 2 c) (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))))

rewrite27.0ms

Algorithm
rewrite-expression-head
Counts
4 → 62
Calls

4 calls. Slowest were:

16.0ms
(/ (* 2 c) (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))))
5.0ms
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
2.0ms
(- (* b b) (* (* 4 a) c))

series324.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

170.0ms
(/ (* 2 c) (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))))
57.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
53.0ms
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
44.0ms
(- (* b b) (* (* 4 a) c))

simplify2.2s

Counts
37 → 74
Calls

37 calls. Slowest were:

372.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
361.0ms
(+ (* (- b) (- b)) (- (* (sqrt (- (* b b) (* (* 4 a) c))) (sqrt (- (* b b) (* (* 4 a) c)))) (* (- b) (sqrt (- (* b b) (* (* 4 a) c))))))
182.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 4 a) c) (* (* 4 a) c))))

prune1.6s

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 6.1b

localize133.0ms

Local error

Found 4 expressions with local error:

24.1b
(sqrt (- (* b b) (* (* 4 a) c)))
1.2b
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
0.8b
(- (* b b) (* (* 4 a) c))
0.1b
(* (* 2 c) (/ 1 (+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))))

rewrite26.0ms

Algorithm
rewrite-expression-head
Counts
4 → 60
Calls

4 calls. Slowest were:

10.0ms
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
7.0ms
(* (* 2 c) (/ 1 (+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))))
4.0ms
(sqrt (- (* b b) (* (* 4 a) c)))

series310.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

149.0ms
(* (* 2 c) (/ 1 (+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))))
71.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
57.0ms
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
33.0ms
(- (* b b) (* (* 4 a) c))

simplify2.8s

Counts
33 → 72
Calls

33 calls. Slowest were:

485.0ms
(* (* (* (* 2 c) (* 2 c)) (* 2 c)) (* (* (/ 1 (+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))) (/ 1 (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))))) (/ 1 (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))))))
387.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
373.0ms
(+ (* (- b) (- b)) (- (* (sqrt (- (* b b) (* (* 4 a) c))) (sqrt (- (* b b) (* (* 4 a) c)))) (* (- b) (sqrt (- (* b b) (* (* 4 a) c))))))

prune1.2s

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 6.1b

regimes421.0ms

Accuracy

87.6% (1.8b remaining)

Error of 8.3b against oracle of 6.5b and baseline of 21.2b

bsearch333.0ms