Average Error: 33.1 → 6.5
Time: 19.9s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -2.074336923720548 \cdot 10^{+100}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le -4.1996115297456014 \cdot 10^{-247}:\\ \;\;\;\;\frac{1}{a} \cdot \left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right)\\ \mathbf{elif}\;b_2 \le 1.8812121325960807 \cdot 10^{+75}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b_2

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_2 < -2.074336923720548e+100

    1. Initial program 45.9

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Initial simplification45.9

      \[\leadsto \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\]
    3. Taylor expanded around -inf 3.6

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}}\]

    if -2.074336923720548e+100 < b_2 < -4.1996115297456014e-247

    1. Initial program 7.9

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Initial simplification7.9

      \[\leadsto \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\]
    3. Using strategy rm
    4. Applied div-inv8.0

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

    if -4.1996115297456014e-247 < b_2 < 1.8812121325960807e+75

    1. Initial program 27.8

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Initial simplification27.8

      \[\leadsto \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\]
    3. Using strategy rm
    4. Applied div-inv27.8

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Using strategy rm
    6. Applied flip--28.0

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}} \cdot \frac{1}{a}\]
    7. Applied associate-*l/28.0

      \[\leadsto \color{blue}{\frac{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2\right) \cdot \frac{1}{a}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}\]
    8. Simplified15.5

      \[\leadsto \frac{\color{blue}{\frac{\left(-a \cdot c\right) + 0}{a}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    9. Taylor expanded around 0 8.9

      \[\leadsto \frac{\color{blue}{-1 \cdot c}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    10. Simplified8.9

      \[\leadsto \frac{\color{blue}{-c}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]

    if 1.8812121325960807e+75 < b_2

    1. Initial program 57.7

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Initial simplification57.7

      \[\leadsto \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\]
    3. Using strategy rm
    4. Applied div-inv57.7

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Taylor expanded around inf 3.7

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b_2}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.074336923720548 \cdot 10^{+100}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le -4.1996115297456014 \cdot 10^{-247}:\\ \;\;\;\;\frac{1}{a} \cdot \left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right)\\ \mathbf{elif}\;b_2 \le 1.8812121325960807 \cdot 10^{+75}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

herbie shell --seed 2018362 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))

Details

Time bar (total: 13.4s)Debug log

start238.0ms

Algorithm
intervals

setup68.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 30.9b

localize55.0ms

Local error

Found 4 expressions with local error:

21.8b
(sqrt (- (* b_2 b_2) (* a c)))
1.8b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.4b
(- (* b_2 b_2) (* a c))
0.4b
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)

rewrite63.0ms

Algorithm
rewrite-expression-head
Counts
4 → 53
Calls

4 calls. Slowest were:

27.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
21.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
9.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series237.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

72.0ms
(sqrt (- (* b_2 b_2) (* a c)))
71.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
65.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
29.0ms
(- (* b_2 b_2) (* a c))

simplify1.4s

Counts
24 → 65
Calls

24 calls. Slowest were:

323.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))
279.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
189.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))

prune665.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 4.2b

localize7.0ms

Local error

Found 4 expressions with local error:

21.8b
(sqrt (- (* b_2 b_2) (* a c)))
1.8b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.5b
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))
0.4b
(- (* b_2 b_2) (* a c))

rewrite57.0ms

Algorithm
rewrite-expression-head
Counts
4 → 61
Calls

4 calls. Slowest were:

42.0ms
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))
11.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
2.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series211.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

68.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
65.0ms
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))
44.0ms
(sqrt (- (* b_2 b_2) (* a c)))
34.0ms
(- (* b_2 b_2) (* a c))

simplify3.3s

Counts
34 → 73
Calls

34 calls. Slowest were:

688.0ms
(* (* (* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (- (sqrt (- (* b_2 b_2) (* a c))) b_2)) (- (sqrt (- (* b_2 b_2) (* a c))) b_2)) (* (* (/ 1 a) (/ 1 a)) (/ 1 a)))
461.0ms
(* (- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2)) 1)
301.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))

prune818.0ms

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 4.2b

localize27.0ms

Local error

Found 4 expressions with local error:

21.8b
(sqrt (- (* b_2 b_2) (* a c)))
10.6b
(/ (+ (- (* a c)) 0) a)
0.9b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.4b
(- (* b_2 b_2) (* a c))

rewrite40.0ms

Algorithm
rewrite-expression-head
Counts
4 → 52
Calls

4 calls. Slowest were:

16.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
15.0ms
(/ (+ (- (* a c)) 0) a)
4.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series158.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

63.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
60.0ms
(sqrt (- (* b_2 b_2) (* a c)))
20.0ms
(- (* b_2 b_2) (* a c))
15.0ms
(/ (+ (- (* a c)) 0) a)

simplify1.7s

Counts
24 → 64
Calls

24 calls. Slowest were:

426.0ms
(+ (pow (- (* a c)) 3) (pow 0 3))
286.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
257.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))

prune736.0ms

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 4.2b

localize6.0ms

Local error

Found 4 expressions with local error:

21.8b
(sqrt (- (* b_2 b_2) (* a c)))
0.9b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.4b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))

rewrite34.0ms

Algorithm
rewrite-expression-head
Counts
4 → 71
Calls

4 calls. Slowest were:

15.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
11.0ms
(/ (- c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))
4.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series244.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

138.0ms
(/ (- c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))
49.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
37.0ms
(sqrt (- (* b_2 b_2) (* a c)))
21.0ms
(- (* b_2 b_2) (* a c))

simplify1.7s

Counts
54 → 83
Calls

54 calls. Slowest were:

302.0ms
(/ (* (* (- c) (- c)) (- c)) (* (* (+ (sqrt (- (* b_2 b_2) (* a c))) b_2) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
283.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
247.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))

prune788.0ms

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 4.2b

regimes360.0ms

Accuracy

94.7% (1.2b remaining)

Error of 6.5b against oracle of 5.2b and baseline of 28.7b

bsearch456.0ms