Average Error: 33.1 → 6.6
Time: 15.7s
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.9119238138439096 \cdot 10^{+56}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 3.651050352237012 \cdot 10^{-278}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 8.494949026334007 \cdot 10^{+94}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{{b_2}^{2} - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 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.9119238138439096e+56

    1. Initial program 56.3

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around -inf 3.6

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

    if -2.9119238138439096e+56 < b_2 < 3.651050352237012e-278

    1. Initial program 28.3

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--28.5

      \[\leadsto \frac{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Applied associate-/l/33.3

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

      \[\leadsto \frac{\color{blue}{a \cdot c}}{a \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}\]
    6. Using strategy rm
    7. Applied times-frac9.3

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

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

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

    if 3.651050352237012e-278 < b_2 < 8.494949026334007e+94

    1. Initial program 8.5

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around 0 8.5

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

    if 8.494949026334007e+94 < b_2

    1. Initial program 44.1

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around inf 3.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.9119238138439096 \cdot 10^{+56}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 3.651050352237012 \cdot 10^{-278}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 8.494949026334007 \cdot 10^{+94}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{{b_2}^{2} - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \end{array}\]

Reproduce

herbie shell --seed 2019021 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))

Details

Time bar (total: 14.9s)Debug log

sample427.0ms

Algorithm
intervals
Results
158.0ms189×body80valid
35.0ms76×body80nan
28.0ms33×body2560valid
18.0ms33×body1280valid
7.0ms13×body640valid
7.0msbody5120valid
3.0msbody320valid
1.0msbody160valid

simplify107.0ms

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

prune15.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 34.4b

localize42.0ms

Local error

Found 4 expressions with local error:

22.6b
(sqrt (- (* b_2 b_2) (* a c)))
1.4b
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
0.6b
(- (* b_2 b_2) (* a c))
0.2b
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)

rewrite44.0ms

Algorithm
rewrite-expression-head
Rules
15×add-sqr-sqrt
10×*-un-lft-identity
add-log-exp
associate-/l*
add-cube-cbrt
sqrt-prod
difference-of-squares
flip--
add-exp-log
add-cbrt-cube
flip3--
pow1
associate-/l/
distribute-lft-out--
diff-log
sqrt-div
sub-neg
div-inv
div-sub
pow1/2
frac-2neg
clear-num
rem-sqrt-square
neg-sub0
associate--l-
Counts
4 → 61
Calls
4 calls:
Slowest
18.0ms
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
18.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
4.0ms
(sqrt (- (* b_2 b_2) (* a c)))
2.0ms
(- (* b_2 b_2) (* a c))

series200.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
68.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
58.0ms
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
50.0ms
(sqrt (- (* b_2 b_2) (* a c)))
24.0ms
(- (* b_2 b_2) (* a c))

simplify1.5s

Counts
32 → 73
Calls
32 calls:
Slowest
268.0ms
(- (pow (- b_2) 3) (pow (sqrt (- (* b_2 b_2) (* a c))) 3))
215.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
205.0ms
(- (* (- b_2) (- b_2)) (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))))
186.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
121.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune761.0ms

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 5.6b

localize8.0ms

Local error

Found 4 expressions with local error:

22.6b
(sqrt (- (* b_2 b_2) (* a c)))
17.2b
(/ (* a c) (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))))
1.1b
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
0.6b
(- (* b_2 b_2) (* a c))

rewrite18.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
*-un-lft-identity
add-exp-log
add-cbrt-cube
add-sqr-sqrt
add-cube-cbrt
pow1
sqrt-prod
flip--
flip-+
associate-/r/
associate-*r/
sqrt-div
flip3--
flip3-+
associate-/l*
distribute-lft-out
div-inv
associate-+l-
div-exp
diff-log
pow1/2
times-frac
frac-2neg
sub-neg
sum-log
associate-/r*
clear-num
rem-sqrt-square
+-commutative
cbrt-undiv
neg-sub0
Counts
4 → 56
Calls
4 calls:
Slowest
6.0ms
(/ (* a c) (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))))
5.0ms
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
3.0ms
(- (* b_2 b_2) (* a c))
2.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series262.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
130.0ms
(/ (* a c) (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))))
55.0ms
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
49.0ms
(sqrt (- (* b_2 b_2) (* a c)))
29.0ms
(- (* b_2 b_2) (* a c))

simplify2.0s

Counts
28 → 68
Calls
28 calls:
Slowest
497.0ms
(- (log (* a c)) (log (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))))))
292.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
245.0ms
(/ (* (* (* a c) (* a c)) (* a c)) (* (* (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))) (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))))) (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))))))
235.0ms
(+ (* (- b_2) (- b_2)) (- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* (- b_2) (sqrt (- (* b_2 b_2) (* a c))))))
209.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))

prune636.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 5.6b

localize16.0ms

Local error

Found 4 expressions with local error:

22.6b
(sqrt (- (* b_2 b_2) (* a c)))
1.1b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.6b
(- (* b_2 b_2) (* a c))
0.1b
(/ c (- (sqrt (- (* b_2 b_2) (* a c))) b_2))

rewrite23.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
sqrt-prod
associate-/r*
associate-/r/
sqrt-div
sub-neg
div-inv
diff-log
pow1/2
frac-2neg
clear-num
rem-sqrt-square
Counts
4 → 52
Calls
4 calls:
Slowest
10.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
8.0ms
(/ c (- (sqrt (- (* b_2 b_2) (* a c))) b_2))
3.0ms
(sqrt (- (* b_2 b_2) (* a c)))
2.0ms
(- (* b_2 b_2) (* a c))

series270.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
146.0ms
(/ c (- (sqrt (- (* b_2 b_2) (* a c))) b_2))
62.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
36.0ms
(sqrt (- (* b_2 b_2) (* a c)))
26.0ms
(- (* b_2 b_2) (* a c))

simplify1.0s

Counts
24 → 64
Calls
24 calls:
Slowest
294.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
206.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
115.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)))
103.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
77.0ms
(- (* 1/2 (/ (* a c) b_2)) (* 2 b_2))

prune581.0ms

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 5.6b

localize16.0ms

Local error

Found 4 expressions with local error:

22.6b
(sqrt (- (* b_2 b_2) (* a c)))
16.4b
(- (exp (log (sqrt (- (* b_2 b_2) (* a c))))) b_2)
5.5b
(exp (log (sqrt (- (* b_2 b_2) (* a c)))))
0.6b
(- (* b_2 b_2) (* a c))

rewrite38.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
add-log-exp
sqrt-prod
exp-sum
log-prod
exp-prod
pow1
flip--
add-exp-log
sqrt-div
add-cbrt-cube
flip3--
log-pow
exp-diff
pow1/2
sub-neg
log-div
rem-exp-log
diff-log
rem-sqrt-square
Counts
4 → 58
Calls
4 calls:
Slowest
30.0ms
(- (exp (log (sqrt (- (* b_2 b_2) (* a c))))) b_2)
3.0ms
(exp (log (sqrt (- (* b_2 b_2) (* a c)))))
2.0ms
(sqrt (- (* b_2 b_2) (* a c)))
2.0ms
(- (* b_2 b_2) (* a c))

series165.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
59.0ms
(- (exp (log (sqrt (- (* b_2 b_2) (* a c))))) b_2)
43.0ms
(sqrt (- (* b_2 b_2) (* a c)))
40.0ms
(exp (log (sqrt (- (* b_2 b_2) (* a c)))))
24.0ms
(- (* b_2 b_2) (* a c))

simplify1.7s

Counts
33 → 70
Calls
33 calls:
Slowest
325.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
307.0ms
(exp (log (sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))))
216.0ms
(exp (log (sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))))
213.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
131.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune762.0ms

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 5.6b

regimes286.0ms

Accuracy

94.9% (1.2b remaining)

Error of 6.6b against oracle of 5.4b and baseline of 29.3b

bsearch386.0ms

end0.0ms

sample3.7s

Algorithm
intervals
Results
1.1s5905×body80valid
881.0ms1099×body2560valid
709.0ms867×body1280valid
395.0ms2859×body80nan
233.0ms447×body640valid
125.0ms118×body5120valid
118.0ms223×body320valid
21.0ms99×body160valid