Average Error: 19.2 → 8.4
Time: 23.3s
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 -1.3544938748628678 \cdot 10^{+154}:\\ \;\;\;\;\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}{\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}\\ \end{array}\\ \mathbf{elif}\;b \le 1.883887850021942 \cdot 10^{+99}:\\ \;\;\;\;\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{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{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}\]

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 < -1.3544938748628678e+154

    1. Initial program 37.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 5.8

      \[\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}:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}}\\ \end{array}\]

    if -1.3544938748628678e+154 < b < 1.883887850021942e+99

    1. Initial program 8.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-cbrt8.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-prod8.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. Simplified8.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 1.883887850021942e+99 < b

    1. Initial program 44.5

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{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. Recombined 3 regimes into one program.
  4. Final simplification8.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.3544938748628678 \cdot 10^{+154}:\\ \;\;\;\;\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}{\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}\\ \end{array}\\ \mathbf{elif}\;b \le 1.883887850021942 \cdot 10^{+99}:\\ \;\;\;\;\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{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{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}\]

Reproduce

herbie shell --seed 2019004 
(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: 22.3s)Debug log

sample115.0ms

Algorithm
intervals

simplify133.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune25.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 18.2b

localize137.0ms

Local error

Found 4 expressions with local error:

22.0b
(sqrt (- (* b b) (* (* 4 a) c)))
22.0b
(sqrt (- (* b b) (* (* 4 a) c)))
0.9b
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
0.8b
(- (* b b) (* (* 4 a) c))

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
4 → 56
Calls

4 calls. Slowest were:

6.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
2.0ms
(- (* b b) (* (* 4 a) c))
2.0ms
(sqrt (- (* b b) (* (* 4 a) c)))

series217.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

72.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
66.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
53.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
26.0ms
(- (* b b) (* (* 4 a) c))

simplify2.4s

Counts
31 → 68
Calls

31 calls. Slowest were:

491.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
403.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
174.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 4 a) c) (* (* 4 a) c))))

prune919.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 8.1b

localize131.0ms

Local error

Found 4 expressions with local error:

22.0b
(sqrt (- (* b b) (* (* 4 a) c)))
22.0b
(sqrt (- (* b b) (* (* 4 a) c)))
22.0b
(sqrt (- (* b b) (* (* 4 a) c)))
13.6b
(- (- b) (* (sqrt (sqrt (- (* b b) (* (* 4 a) c)))) (sqrt (sqrt (- (* b b) (* (* 4 a) c))))))

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
4 → 56
Calls

4 calls. Slowest were:

6.0ms
(- (- b) (* (sqrt (sqrt (- (* b b) (* (* 4 a) c)))) (sqrt (sqrt (- (* b b) (* (* 4 a) c))))))
2.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
2.0ms
(sqrt (- (* b b) (* (* 4 a) c)))

series260.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

68.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
66.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
64.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
60.0ms
(- (- b) (* (sqrt (sqrt (- (* b b) (* (* 4 a) c)))) (sqrt (sqrt (- (* b b) (* (* 4 a) c))))))

simplify3.1s

Counts
33 → 68
Calls

33 calls. Slowest were:

471.0ms
(/ (exp (- b)) (exp (* (sqrt (sqrt (- (* b b) (* (* 4 a) c)))) (sqrt (sqrt (- (* b b) (* (* 4 a) c)))))))
378.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
360.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))

prune1.2s

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 8.1b

localize139.0ms

Local error

Found 4 expressions with local error:

22.7b
(cbrt (- (* b b) (* (* 4 a) c)))
22.7b
(cbrt (- (* b b) (* (* 4 a) c)))
22.0b
(sqrt (- (* b b) (* (* 4 a) c)))
9.2b
(- (- b) (* (fabs (cbrt (- (* b b) (* (* 4 a) c)))) (sqrt (cbrt (- (* b b) (* (* 4 a) c))))))

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
4 → 53
Calls

4 calls. Slowest were:

4.0ms
(- (- b) (* (fabs (cbrt (- (* b b) (* (* 4 a) c)))) (sqrt (cbrt (- (* b b) (* (* 4 a) c))))))
2.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
2.0ms
(cbrt (- (* b b) (* (* 4 a) c)))

series390.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

129.0ms
(cbrt (- (* b b) (* (* 4 a) c)))
109.0ms
(- (- b) (* (fabs (cbrt (- (* b b) (* (* 4 a) c)))) (sqrt (cbrt (- (* b b) (* (* 4 a) c))))))
91.0ms
(cbrt (- (* b b) (* (* 4 a) c)))
61.0ms
(sqrt (- (* b b) (* (* 4 a) c)))

simplify3.1s

Counts
29 → 65
Calls

29 calls. Slowest were:

434.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
379.0ms
(cbrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
373.0ms
(cbrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))

prune1.3s

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 8.1b

localize160.0ms

Local error

Found 4 expressions with local error:

22.0b
(sqrt (- (* b b) (* (* 4 a) c)))
22.0b
(sqrt (- (* b b) (* (* 4 a) c)))
22.0b
(sqrt (- (* b b) (* (* 4 a) c)))
22.0b
(sqrt (- (* b b) (* (* 4 a) c)))

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

series245.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

70.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
65.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
59.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
50.0ms
(sqrt (- (* b b) (* (* 4 a) c)))

simplify3.4s

Counts
36 → 68
Calls

36 calls. Slowest were:

442.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
409.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
380.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))

prune1.1s

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 8.1b

regimes298.0ms

Accuracy

91.9% (1.0b remaining)

Error of 8.4b against oracle of 7.4b and baseline of 19.4b

bsearch398.0ms

end0.0ms

sample3.1s

Algorithm
intervals