Average Error: 20.3 → 8.9
Time: 25.1s
Precision: 64
Internal Precision: 128
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -4.4165345932310753 \cdot 10^{+135}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(2 \cdot \frac{a \cdot c}{b} - b\right) + \left(-b\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \le 7.564155873244899 \cdot 10^{+99}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\sqrt[3]{\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[3]{\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}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a}\\ \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 < -4.4165345932310753e+135

    1. Initial program 54.4

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

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

    if -4.4165345932310753e+135 < b < 7.564155873244899e+99

    1. Initial program 9.0

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\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}\\ \end{array}\]
    4. Applied sqrt-prod9.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \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}\\ \end{array}\]
    5. Simplified9.2

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left|\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right| \cdot \sqrt{\sqrt[3]{\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}\\ \end{array}\]
    8. Applied cbrt-prod9.3

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

    if 7.564155873244899e+99 < b

    1. Initial program 30.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.4165345932310753 \cdot 10^{+135}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(2 \cdot \frac{a \cdot c}{b} - b\right) + \left(-b\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \le 7.564155873244899 \cdot 10^{+99}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\sqrt[3]{\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[3]{\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}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 24.0s)Debug log

sample124.0ms

Algorithm
intervals

simplify107.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

107.0ms
(if (>= b 0) (/ (* 2 c) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))

prune32.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 22.1b

localize185.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.7b
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
1.5b
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))

rewrite24.0ms

Algorithm
rewrite-expression-head
Counts
4 → 57
Calls

4 calls. Slowest were:

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

series250.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

77.0ms
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
74.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
53.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
46.0ms
(sqrt (- (* b b) (* (* 4 a) c)))

simplify2.3s

Counts
32 → 69
Calls

32 calls. Slowest were:

419.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
371.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
153.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 4 a) c) (* (* 4 a) c))))

prune1.0s

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 9.4b

localize145.0ms

Local error

Found 4 expressions with local error:

24.9b
(cbrt (- (* b b) (* (* 4 a) c)))
24.9b
(cbrt (- (* b b) (* (* 4 a) c)))
24.1b
(sqrt (- (* b b) (* (* 4 a) c)))
9.0b
(+ (- b) (* (fabs (cbrt (- (* b b) (* (* 4 a) c)))) (sqrt (cbrt (- (* b b) (* (* 4 a) c))))))

rewrite19.0ms

Algorithm
rewrite-expression-head
Counts
4 → 52
Calls

4 calls. Slowest were:

8.0ms
(+ (- b) (* (fabs (cbrt (- (* b b) (* (* 4 a) c)))) (sqrt (cbrt (- (* b b) (* (* 4 a) c))))))
4.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
3.0ms
(cbrt (- (* b b) (* (* 4 a) c)))

series389.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

115.0ms
(cbrt (- (* b b) (* (* 4 a) c)))
108.0ms
(+ (- b) (* (fabs (cbrt (- (* b b) (* (* 4 a) c)))) (sqrt (cbrt (- (* b b) (* (* 4 a) c))))))
100.0ms
(cbrt (- (* b b) (* (* 4 a) c)))
66.0ms
(sqrt (- (* b b) (* (* 4 a) c)))

simplify3.0s

Counts
29 → 64
Calls

29 calls. Slowest were:

489.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
378.0ms
(cbrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
291.0ms
(cbrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))

prune1.3s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 9.4b

localize153.0ms

Local error

Found 4 expressions with local error:

24.9b
(cbrt (- (* b b) (* (* 4 a) c)))
24.9b
(cbrt (- (* b b) (* (* 4 a) c)))
24.9b
(cbrt (- (* b b) (* (* 4 a) c)))
24.9b
(cbrt (- (* b b) (* (* 4 a) c)))

rewrite6.0ms

Algorithm
rewrite-expression-head
Counts
4 → 52
Calls

4 calls. Slowest were:

1.0ms
(cbrt (- (* b b) (* (* 4 a) c)))
1.0ms
(cbrt (- (* b b) (* (* 4 a) c)))
1.0ms
(cbrt (- (* b b) (* (* 4 a) c)))

series431.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

130.0ms
(cbrt (- (* b b) (* (* 4 a) c)))
109.0ms
(cbrt (- (* b b) (* (* 4 a) c)))
96.0ms
(cbrt (- (* b b) (* (* 4 a) c)))
96.0ms
(cbrt (- (* b b) (* (* 4 a) c)))

simplify3.6s

Counts
32 → 64
Calls

32 calls. Slowest were:

476.0ms
(cbrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
371.0ms
(cbrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
362.0ms
(cbrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))

prune1.5s

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 9.4b

localize126.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)))
24.1b
(sqrt (- (* b b) (* (* 4 a) c)))
24.1b
(sqrt (- (* b b) (* (* 4 a) c)))

rewrite17.0ms

Algorithm
rewrite-expression-head
Counts
4 → 56
Calls

4 calls. Slowest were:

4.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
4.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
4.0ms
(sqrt (- (* b b) (* (* 4 a) c)))

series253.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

68.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
67.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
64.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
55.0ms
(sqrt (- (* b b) (* (* 4 a) c)))

simplify3.6s

Counts
36 → 68
Calls

36 calls. Slowest were:

698.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
441.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
406.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))

prune1.2s

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 9.4b

regimes324.0ms

Accuracy

91.8% (1.0b remaining)

Error of 8.9b against oracle of 7.9b and baseline of 20.5b

bsearch456.0ms

end0.0ms

sample3.3s

Algorithm
intervals