Average Error: 33.1 → 6.7
Time: 16.8s
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 -4.1146996886759634 \cdot 10^{+123}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le -5.4415579011733295 \cdot 10^{-244}:\\ \;\;\;\;\frac{\sqrt{{b_2}^{2} - c \cdot a}}{a} - \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 3.961022245802818 \cdot 10^{+65}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{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 < -4.1146996886759634e+123

    1. Initial program 49.0

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified49.0

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

      \[\leadsto \frac{\sqrt{\color{blue}{{b_2}^{2} - a \cdot c}} - b_2}{a}\]
    4. Taylor expanded around -inf 3.2

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

    if -4.1146996886759634e+123 < b_2 < -5.4415579011733295e-244

    1. Initial program 8.3

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified8.3

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

      \[\leadsto \frac{\sqrt{\color{blue}{{b_2}^{2} - a \cdot c}} - b_2}{a}\]
    4. Using strategy rm
    5. Applied div-sub8.3

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

    if -5.4415579011733295e-244 < b_2 < 3.961022245802818e+65

    1. Initial program 28.0

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified28.0

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

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

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

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

      \[\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 -inf 9.6

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

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

    if 3.961022245802818e+65 < b_2

    1. Initial program 56.5

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified56.5

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-inv56.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -4.1146996886759634 \cdot 10^{+123}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le -5.4415579011733295 \cdot 10^{-244}:\\ \;\;\;\;\frac{\sqrt{{b_2}^{2} - c \cdot a}}{a} - \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 3.961022245802818 \cdot 10^{+65}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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

sample276.0ms

Algorithm
intervals

simplify46.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
45.0ms
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)

prune45.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 32.9b

localize37.0ms

Local error

Found 4 expressions with local error:

22.0b
(sqrt (- (* b_2 b_2) (* a c)))
1.7b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.2b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)

rewrite73.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-log-exp
add-cube-cbrt
*-un-lft-identity
flip--
add-exp-log
add-cbrt-cube
flip3--
pow1
associate-/l*
sqrt-prod
associate-/l/
sqrt-div
sub-neg
div-inv
div-sub
diff-log
pow1/2
frac-2neg
clear-num
rem-sqrt-square
Counts
4 → 53
Calls
4 calls:
Slowest
40.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
20.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
6.0ms
(sqrt (- (* b_2 b_2) (* a c)))
4.0ms
(- (* b_2 b_2) (* a c))

series611.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
446.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
72.0ms
(sqrt (- (* b_2 b_2) (* a c)))
58.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
34.0ms
(- (* b_2 b_2) (* a c))

simplify1.3s

Counts
24 → 65
Calls
24 calls:
Slowest
283.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))
241.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
224.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
134.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
103.0ms
(- (pow (sqrt (- (* b_2 b_2) (* a c))) 3) (pow b_2 3))

prune633.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 6.3b

localize27.0ms

Local error

Found 4 expressions with local error:

22.0b
(sqrt (- (pow b_2 2) (* a c)))
1.7b
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
0.2b
(- (pow b_2 2) (* a c))
0.1b
(/ (- (sqrt (- (pow b_2 2) (* a c))) b_2) a)

rewrite65.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-log-exp
add-cube-cbrt
*-un-lft-identity
flip--
add-exp-log
add-cbrt-cube
flip3--
pow1
associate-/l*
sqrt-prod
associate-/l/
sqrt-div
sub-neg
div-inv
div-sub
diff-log
pow1/2
frac-2neg
clear-num
rem-sqrt-square
Counts
4 → 53
Calls
4 calls:
Slowest
30.0ms
(/ (- (sqrt (- (pow b_2 2) (* a c))) b_2) a)
25.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
6.0ms
(sqrt (- (pow b_2 2) (* a c)))
3.0ms
(- (pow b_2 2) (* a c))

series193.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
65.0ms
(/ (- (sqrt (- (pow b_2 2) (* a c))) b_2) a)
50.0ms
(sqrt (- (pow b_2 2) (* a c)))
50.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
27.0ms
(- (pow b_2 2) (* a c))

simplify1.6s

Counts
24 → 65
Calls
24 calls:
Slowest
414.0ms
(sqrt (- (pow (pow b_2 2) 3) (pow (* a c) 3)))
370.0ms
(- (* (sqrt (- (pow b_2 2) (* a c))) (sqrt (- (pow b_2 2) (* a c)))) (* b_2 b_2))
252.0ms
(sqrt (- (* (pow b_2 2) (pow b_2 2)) (* (* a c) (* a c))))
155.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
70.0ms
(- (* 1/2 (/ (* a c) b_2)) (* 2 b_2))

prune669.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 6.3b

localize11.0ms

Local error

Found 4 expressions with local error:

22.0b
(sqrt (- (* b_2 b_2) (* a c)))
1.7b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.2b
(- (* b_2 b_2) (* a c))
0.2b
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))

rewrite40.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
add-log-exp
add-exp-log
add-cbrt-cube
pow1
flip--
flip3--
associate-*r*
sqrt-prod
associate-*l*
associate-*l/
sqrt-div
sub-neg
frac-times
div-inv
cbrt-unprod
*-commutative
un-div-inv
associate-*r/
prod-exp
pow-prod-down
diff-log
pow1/2
rem-sqrt-square
Counts
4 → 61
Calls
4 calls:
Slowest
26.0ms
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))
10.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
2.0ms
(sqrt (- (* b_2 b_2) (* a c)))
2.0ms
(- (* b_2 b_2) (* a c))

series202.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
60.0ms
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))
59.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
50.0ms
(sqrt (- (* b_2 b_2) (* a c)))
32.0ms
(- (* b_2 b_2) (* a c))

simplify2.6s

Counts
34 → 73
Calls
34 calls:
Slowest
393.0ms
(* (- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2)) 1)
327.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
308.0ms
(* (+ (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (+ (* b_2 b_2) (* (sqrt (- (* b_2 b_2) (* a c))) b_2))) a)
285.0ms
(* (- (pow (sqrt (- (* b_2 b_2) (* a c))) 3) (pow b_2 3)) 1)
254.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)))

prune693.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 6.2b

localize15.0ms

Local error

Found 4 expressions with local error:

22.0b
(sqrt (- (* b_2 b_2) (* a c)))
14.3b
(/ (+ (- (* a c)) 0) a)
0.4b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.2b
(- (* b_2 b_2) (* a c))

rewrite28.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-log-exp
add-cube-cbrt
*-un-lft-identity
add-exp-log
add-cbrt-cube
pow1
associate-/l*
sqrt-prod
associate-/l/
flip--
flip-+
sqrt-div
flip3--
flip3-+
div-inv
associate-+l-
div-sub
diff-log
pow1/2
frac-2neg
sub-neg
clear-num
rem-sqrt-square
+-commutative
neg-sub0
Counts
4 → 52
Calls
4 calls:
Slowest
15.0ms
(/ (+ (- (* a c)) 0) a)
9.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
2.0ms
(sqrt (- (* b_2 b_2) (* a c)))
2.0ms
(- (* b_2 b_2) (* a c))

series116.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
51.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
36.0ms
(sqrt (- (* b_2 b_2) (* a c)))
20.0ms
(- (* b_2 b_2) (* a c))
9.0ms
(/ (+ (- (* a c)) 0) a)

simplify1.6s

Counts
24 → 64
Calls
24 calls:
Slowest
435.0ms
(+ (pow (- (* a c)) 3) (pow 0 3))
227.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
209.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
195.0ms
(- (* (- (* a c)) (- (* a c))) (* 0 0))
167.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune736.0ms

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 6.2b

regimes316.0ms

Accuracy

95% (1.2b remaining)

Error of 6.7b against oracle of 5.5b and baseline of 29.4b

bsearch358.0ms

end1.0ms

sample3.9s

Algorithm
intervals