Average Error: 33.3 → 6.4
Time: 20.4s
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 -6.504819251117985 \cdot 10^{+152}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.626169288079444 \cdot 10^{-277}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}\\ \mathbf{elif}\;b_2 \le 4.8003163493567134 \cdot 10^{+126}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{{b_2}^{2} - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \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 < -6.504819251117985e+152

    1. Initial program 62.8

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

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

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

    if -6.504819251117985e+152 < b_2 < -1.626169288079444e-277

    1. Initial program 34.6

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

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

      \[\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}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}} \cdot \frac{1}{a}\]
    6. Applied associate-*l/34.8

      \[\leadsto \color{blue}{\frac{\left(\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}\right) \cdot \frac{1}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    7. Simplified13.4

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

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

    if -1.626169288079444e-277 < b_2 < 4.8003163493567134e+126

    1. Initial program 9.3

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

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

    if 4.8003163493567134e+126 < b_2

    1. Initial program 51.6

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

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

      \[\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}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}} \cdot \frac{1}{a}\]
    6. Applied associate-*l/61.8

      \[\leadsto \color{blue}{\frac{\left(\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}\right) \cdot \frac{1}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    7. Simplified62.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -6.504819251117985 \cdot 10^{+152}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.626169288079444 \cdot 10^{-277}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}\\ \mathbf{elif}\;b_2 \le 4.8003163493567134 \cdot 10^{+126}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{{b_2}^{2} - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

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

sample191.0ms

Algorithm
intervals
Results
26.0ms31×body2560valid
22.0ms188×body80valid
16.0ms27×body1280valid
10.0ms103×body80nan
8.0ms17×body640valid
2.0msbody320valid
2.0msbody5120valid
1.0msbody160valid

simplify81.0ms

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

prune8.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 32.3b

localize31.0ms

Local error

Found 4 expressions with local error:

19.5b
(sqrt (- (* b_2 b_2) (* a c)))
1.2b
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
0.1b
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
0.0b
(- (* b_2 b_2) (* a c))

rewrite71.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
45.0ms
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
12.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
6.0ms
(sqrt (- (* b_2 b_2) (* a c)))
4.0ms
(- (* b_2 b_2) (* a c))

series234.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
79.0ms
(sqrt (- (* b_2 b_2) (* a c)))
68.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
66.0ms
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
21.0ms
(- (* b_2 b_2) (* a c))

simplify1.5s

Counts
32 → 73
Calls
32 calls:
Slowest
262.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
254.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
230.0ms
(- (pow (- b_2) 3) (pow (sqrt (- (* b_2 b_2) (* a c))) 3))
187.0ms
(- (* (- b_2) (- b_2)) (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))))
164.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune708.0ms

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 5.8b

localize20.0ms

Local error

Found 4 expressions with local error:

19.5b
(sqrt (- (pow b_2 2) (* a c)))
1.2b
(- (- b_2) (sqrt (- (pow b_2 2) (* a c))))
0.1b
(/ (- (- b_2) (sqrt (- (pow b_2 2) (* a c)))) a)
0.0b
(- (pow b_2 2) (* a c))

rewrite32.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 (- (pow b_2 2) (* a c)))) a)
7.0ms
(- (- b_2) (sqrt (- (pow b_2 2) (* a c))))
3.0ms
(- (pow b_2 2) (* a c))
3.0ms
(sqrt (- (pow b_2 2) (* a c)))

series210.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
71.0ms
(/ (- (- b_2) (sqrt (- (pow b_2 2) (* a c)))) a)
60.0ms
(sqrt (- (pow b_2 2) (* a c)))
56.0ms
(- (- b_2) (sqrt (- (pow b_2 2) (* a c))))
23.0ms
(- (pow b_2 2) (* a c))

simplify2.2s

Counts
32 → 73
Calls
32 calls:
Slowest
687.0ms
(- (* (- b_2) (- b_2)) (* (sqrt (- (pow b_2 2) (* a c))) (sqrt (- (pow b_2 2) (* a c)))))
333.0ms
(- (pow (- b_2) 3) (pow (sqrt (- (pow b_2 2) (* a c))) 3))
319.0ms
(sqrt (- (pow (pow b_2 2) 3) (pow (* a c) 3)))
264.0ms
(sqrt (- (* (pow b_2 2) (pow b_2 2)) (* (* a c) (* a c))))
116.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune753.0ms

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 5.8b

localize12.0ms

Local error

Found 4 expressions with local error:

19.5b
(sqrt (- (* b_2 b_2) (* a c)))
1.2b
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
0.2b
(* (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) (/ 1 a))
0.0b
(- (* b_2 b_2) (* a c))

rewrite46.0ms

Algorithm
rewrite-expression-head
Rules
16×add-sqr-sqrt
11×*-un-lft-identity
add-log-exp
add-cube-cbrt
add-exp-log
associate-*l*
add-cbrt-cube
pow1
flip--
sqrt-prod
flip3--
difference-of-squares
associate-*r*
distribute-lft-out--
associate-*l/
diff-log
sqrt-div
sub-neg
frac-times
div-inv
cbrt-unprod
*-commutative
un-div-inv
associate-*r/
prod-exp
pow-prod-down
pow1/2
rem-sqrt-square
neg-sub0
associate--l-
Counts
4 → 69
Calls
4 calls:
Slowest
26.0ms
(* (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) (/ 1 a))
11.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
4.0ms
(sqrt (- (* b_2 b_2) (* a c)))
4.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)))) (/ 1 a))
60.0ms
(sqrt (- (* b_2 b_2) (* a c)))
51.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
21.0ms
(- (* b_2 b_2) (* a c))

simplify2.7s

Counts
42 → 81
Calls
42 calls:
Slowest
359.0ms
(* (- (pow (- b_2) 3) (pow (sqrt (- (* b_2 b_2) (* a c))) 3)) 1)
358.0ms
(* (* (* (- (- b_2) (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))))) (* (* (/ 1 a) (/ 1 a)) (/ 1 a)))
277.0ms
(* (- (* (- b_2) (- b_2)) (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c))))) 1)
265.0ms
(* (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) (/ 1 a))
212.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))

prune841.0ms

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 5.8b

localize9.0ms

Local error

Found 4 expressions with local error:

19.5b
(sqrt (- (* b_2 b_2) (* a c)))
13.4b
(/ (* a c) a)
0.1b
(/ (/ (* a c) a) (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))))
0.1b
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))

rewrite37.0ms

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

series212.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
122.0ms
(/ (/ (* a c) a) (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))))
49.0ms
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
36.0ms
(sqrt (- (* b_2 b_2) (* a c)))
5.0ms
(/ (* a c) a)

simplify3.6s

Counts
64 → 89
Calls
64 calls:
Slowest
616.0ms
(- (log (/ (* a c) a)) (log (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))))
327.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
293.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))))))
240.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
240.0ms
(/ (/ (* a c) a) (cbrt (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))))

prune802.0ms

Pruning

8 alts after pruning (6 fresh and 2 done)

Merged error: 5.8b

regimes284.0ms

Accuracy

96.6% (0.8b remaining)

Error of 6.4b against oracle of 5.6b and baseline of 29.0b

bsearch359.0ms

end0.0ms

sample3.8s

Algorithm
intervals
Results
1.2s1084×body2560valid
814.0ms5899×body80valid
648.0ms861×body1280valid
336.0ms2781×body80nan
324.0ms466×body640valid
95.0ms112×body5120valid
70.0ms203×body320valid
28.0ms108×body160valid