Average Error: 19.2 → 7.8
Time: 20.6s
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 -2.101324698489804 \cdot 10^{+137}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \le 5.423498018208401 \cdot 10^{+105}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b + \left(a \cdot -4\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b \cdot b + \left(a \cdot -4\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b + \left(a \cdot -4\right) \cdot c}} - b}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;2 \cdot \frac{\frac{c}{2}}{\frac{c}{b} \cdot a - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\sqrt[3]{a \cdot \left(c \cdot -4\right) + b \cdot b}\right| \cdot \sqrt{\sqrt[3]{b \cdot b + \left(a \cdot -4\right) \cdot c}} - b}{a \cdot 2}\\ \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.101324698489804e+137

    1. Initial program 54.6

      \[\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. Simplified54.6

      \[\leadsto \color{blue}{\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{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \end{array}}\]
    3. Taylor expanded around inf 54.6

      \[\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{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \end{array}\]
    4. Taylor expanded around -inf 12.0

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{2 \cdot a}\\ \end{array}\]

    if -2.101324698489804e+137 < b < 5.423498018208401e+105

    1. Initial program 8.8

      \[\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. Simplified8.8

      \[\leadsto \color{blue}{\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{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \end{array}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt8.8

      \[\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{\sqrt{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c}} - b}{2 \cdot a}\\ \end{array}\]
    5. Applied sqrt-prod8.9

      \[\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{\sqrt{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c}} - b}{2 \cdot a}\\ \end{array}\]

    if 5.423498018208401e+105 < b

    1. Initial program 30.6

      \[\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. Simplified30.6

      \[\leadsto \color{blue}{\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{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \end{array}}\]
    3. Taylor expanded around inf 6.4

      \[\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{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \end{array}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity6.4

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\color{blue}{\frac{2}{1} \cdot \frac{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} - b}{2 \cdot a}\\ \end{array}\]
    7. Simplified6.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\color{blue}{2} \cdot \frac{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} - b}{2 \cdot a}\\ \end{array}\]
    8. Simplified2.4

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;2 \cdot \frac{\frac{c}{2}}{\frac{c}{b} \cdot a - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\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}} - b}{2 \cdot a}\\ \end{array}\]
    12. Simplified2.4

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

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

Reproduce

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

sample74.0ms

Algorithm
intervals

simplify158.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

158.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: 19.3b

localize149.0ms

Local error

Found 4 expressions with local error:

23.6b
(sqrt (+ (* b b) (* (* -4 a) c)))
23.6b
(sqrt (+ (* b b) (* (* -4 a) c)))
1.7b
(- (- b) (sqrt (+ (* b b) (* (* -4 a) c))))
1.3b
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)

rewrite44.0ms

Algorithm
rewrite-expression-head
Counts
4 → 55
Calls

4 calls. Slowest were:

21.0ms
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)
11.0ms
(- (- b) (sqrt (+ (* b b) (* (* -4 a) c))))
6.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))

series282.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

77.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
71.0ms
(- (- b) (sqrt (+ (* b b) (* (* -4 a) c))))
67.0ms
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)
67.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))

simplify1.6s

Counts
30 → 67
Calls

30 calls. Slowest were:

210.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
201.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
157.0ms
(- b (* 2 (/ (* a c) b)))

prune1.2s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 6.3b

localize117.0ms

Local error

Found 4 expressions with local error:

23.6b
(sqrt (+ (* b b) (* (* -4 a) c)))
23.6b
(sqrt (+ (* b b) (* (* -4 a) c)))
23.6b
(sqrt (+ (* b b) (* (* -4 a) c)))
17.1b
(- (* (sqrt (sqrt (+ (* b b) (* (* -4 a) c)))) (sqrt (sqrt (+ (* b b) (* (* -4 a) c))))) b)

rewrite24.0ms

Algorithm
rewrite-expression-head
Counts
4 → 53
Calls

4 calls. Slowest were:

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

series236.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

78.0ms
(- (* (sqrt (sqrt (+ (* b b) (* (* -4 a) c)))) (sqrt (sqrt (+ (* b b) (* (* -4 a) c))))) b)
60.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
55.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
43.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))

simplify2.1s

Counts
30 → 65
Calls

30 calls. Slowest were:

251.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
234.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
202.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))

prune1.1s

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 6.3b

localize131.0ms

Local error

Found 4 expressions with local error:

23.6b
(sqrt (+ (* b b) (* (* -4 a) c)))
4.6b
(/ (* a c) b)
3.4b
(/ (* 2 c) (- (* 2 (/ (* a c) b)) (* 2 b)))
1.3b
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)

rewrite35.0ms

Algorithm
rewrite-expression-head
Counts
4 → 59
Calls

4 calls. Slowest were:

18.0ms
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)
9.0ms
(/ (* 2 c) (- (* 2 (/ (* a c) b)) (* 2 b)))
4.0ms
(/ (* a c) b)

series176.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

56.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
53.0ms
(/ (* 2 c) (- (* 2 (/ (* a c) b)) (* 2 b)))
51.0ms
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)
15.0ms
(/ (* a c) b)

simplify2.3s

Counts
34 → 71
Calls

34 calls. Slowest were:

343.0ms
(/ (* (* (* 2 c) (* 2 c)) (* 2 c)) (* (* (- (* 2 (/ (* a c) b)) (* 2 b)) (- (* 2 (/ (* a c) b)) (* 2 b))) (- (* 2 (/ (* a c) b)) (* 2 b))))
303.0ms
(+ (* (* 2 (/ (* a c) b)) (* 2 (/ (* a c) b))) (+ (* (* 2 b) (* 2 b)) (* (* 2 (/ (* a c) b)) (* 2 b))))
260.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))

prune1.1s

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 5.8b

localize144.0ms

Local error

Found 4 expressions with local error:

23.6b
(sqrt (+ (* b b) (* (* -4 a) c)))
6.0b
(* (/ c b) a)
3.4b
(/ (/ c 2) (- (* (/ c b) a) b))
1.3b
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)

rewrite51.0ms

Algorithm
rewrite-expression-head
Counts
4 → 72
Calls

4 calls. Slowest were:

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

series222.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

85.0ms
(/ (/ c 2) (- (* (/ c b) a) b))
68.0ms
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)
48.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
22.0ms
(* (/ c b) a)

simplify2.0s

Counts
54 → 84
Calls

54 calls. Slowest were:

453.0ms
(+ (* (* (/ c b) a) (* (/ c b) a)) (+ (* b b) (* (* (/ c b) a) b)))
288.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
287.0ms
(/ (* (* (/ c 2) (/ c 2)) (/ c 2)) (* (* (- (* (/ c b) a) b) (- (* (/ c b) a) b)) (- (* (/ c b) a) b)))

prune1.5s

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 5.8b

regimes447.0ms

Accuracy

91.9% (1.0b remaining)

Error of 7.8b against oracle of 6.8b and baseline of 19.2b

bsearch433.0ms

end0.0ms

sample3.3s

Algorithm
intervals