Average Error: 33.2 → 6.8
Time: 21.2s
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 -3.665285315139032 \cdot 10^{+125}:\\ \;\;\;\;(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*\\ \mathbf{elif}\;b_2 \le 1.5010094954833426 \cdot 10^{-229}:\\ \;\;\;\;\frac{\sqrt{{b_2}^{2} - c \cdot a} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 2.5651495066978512 \cdot 10^{+63}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{(2 \cdot b_2 + \left(\frac{\frac{-1}{2} \cdot a}{\frac{b_2}{c}}\right))_*}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -3.665285315139032e+125

    1. Initial program 50.8

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

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

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

      \[\leadsto \color{blue}{(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*}\]

    if -3.665285315139032e+125 < b_2 < 1.5010094954833426e-229

    1. Initial program 9.9

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

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

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

    if 1.5010094954833426e-229 < b_2 < 2.5651495066978512e+63

    1. Initial program 33.1

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

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

      \[\leadsto \frac{\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}}}{a}\]
    5. Applied associate-/l/37.1

      \[\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}{a \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}}\]
    6. Simplified20.9

      \[\leadsto \frac{\color{blue}{-a \cdot c}}{a \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}\]
    7. Using strategy rm
    8. Applied distribute-frac-neg20.9

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

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

    if 2.5651495066978512e+63 < 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 flip--56.6

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

      \[\leadsto \frac{\color{blue}{-a \cdot c}}{a \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}\]
    7. Using strategy rm
    8. Applied distribute-frac-neg29.5

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

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

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

      \[\leadsto -\frac{c}{\color{blue}{(2 \cdot b_2 + \left(\frac{a \cdot \frac{-1}{2}}{\frac{b_2}{c}}\right))_*}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -3.665285315139032 \cdot 10^{+125}:\\ \;\;\;\;(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*\\ \mathbf{elif}\;b_2 \le 1.5010094954833426 \cdot 10^{-229}:\\ \;\;\;\;\frac{\sqrt{{b_2}^{2} - c \cdot a} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 2.5651495066978512 \cdot 10^{+63}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{(2 \cdot b_2 + \left(\frac{\frac{-1}{2} \cdot a}{\frac{b_2}{c}}\right))_*}\\ \end{array}\]

Reproduce

herbie shell --seed 2019016 +o rules:numerics
(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: 20.3s)Debug log

sample294.0ms

Algorithm
intervals
Results
378×(pre true 80)
186×(body real 80)
93×(body nan 80)
36×(body real 2560)
30×(body real 1280)
17×(body real 640)
(body real 160)
(body real 320)
(body real 5120)

simplify51.0ms

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

prune12.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 34.8b

localize21.0ms

Local error

Found 4 expressions with local error:

23.0b
(sqrt (- (* b_2 b_2) (* a c)))
2.2b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
1.2b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)

rewrite891.0ms

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

series227.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
69.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
66.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
63.0ms
(sqrt (- (* b_2 b_2) (* a c)))
29.0ms
(- (* b_2 b_2) (* a c))

simplify2.0s

Counts
31 → 81
Calls
31 calls:
Slowest
466.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
407.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))
309.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
168.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
121.0ms
(- (pow (sqrt (- (* b_2 b_2) (* a c))) 3) (pow b_2 3))

prune947.0ms

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 5.0b

localize21.0ms

Local error

Found 4 expressions with local error:

23.0b
(sqrt (- (* b_2 b_2) (* a c)))
16.1b
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
1.2b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
1.2b
(- (* b_2 b_2) (* a c))

rewrite27.0ms

Algorithm
rewrite-expression-head
Rules
10×add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
add-log-exp
associate-/l*
sqrt-prod
add-exp-log
add-cbrt-cube
times-frac
fma-def
log1p-expm1-u
pow1
expm1-log1p-u
flip--
flip-+
associate-/r/
associate-*r/
sqrt-div
flip3--
flip3-+
distribute-rgt-neg-in
neg-mul-1
distribute-lft-neg-in
div-inv
distribute-frac-neg
prod-diff
div-exp
div-sub
diff-log
fma-neg
pow1/2
frac-2neg
sub-neg
associate-/r*
clear-num
rem-sqrt-square
+-commutative
cbrt-undiv
neg-sub0
Counts
4 → 81
Calls
4 calls:
Slowest
9.0ms
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
9.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
4.0ms
(sqrt (- (* b_2 b_2) (* a c)))
4.0ms
(- (* b_2 b_2) (* a c))

series285.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
126.0ms
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
66.0ms
(sqrt (- (* b_2 b_2) (* a c)))
60.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
33.0ms
(- (* b_2 b_2) (* a c))

simplify2.9s

Counts
48 → 93
Calls
48 calls:
Slowest
522.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
467.0ms
(/ (* (* (- (* a c)) (- (* a c))) (- (* a c))) (* (* (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))))
379.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)))
339.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
247.0ms
(/ (* a c) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))

prune909.0ms

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 5.0b

localize16.0ms

Local error

Found 4 expressions with local error:

23.0b
(sqrt (- (* b_2 b_2) (* a c)))
1.2b
(+ b_2 (sqrt (- (* b_2 b_2) (* a c))))
1.2b
(- (* b_2 b_2) (* a c))
0.1b
(/ c (+ b_2 (sqrt (- (* b_2 b_2) (* a c)))))

rewrite17.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-log-exp
add-cube-cbrt
*-un-lft-identity
log1p-expm1-u
add-exp-log
add-cbrt-cube
pow1
expm1-log1p-u
sqrt-prod
associate-/r*
flip--
flip-+
associate-/r/
sqrt-div
flip3--
flip3-+
div-inv
prod-diff
diff-log
fma-neg
pow1/2
frac-2neg
sub-neg
clear-num
rem-sqrt-square
+-commutative
Counts
4 → 61
Calls
4 calls:
Slowest
6.0ms
(sqrt (- (* b_2 b_2) (* a c)))
4.0ms
(- (* b_2 b_2) (* a c))
3.0ms
(+ b_2 (sqrt (- (* b_2 b_2) (* a c))))
3.0ms
(/ c (+ b_2 (sqrt (- (* b_2 b_2) (* a c)))))

series258.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
135.0ms
(/ c (+ b_2 (sqrt (- (* b_2 b_2) (* a c)))))
56.0ms
(+ b_2 (sqrt (- (* b_2 b_2) (* a c))))
47.0ms
(sqrt (- (* b_2 b_2) (* a c)))
20.0ms
(- (* b_2 b_2) (* a c))

simplify1.5s

Counts
26 → 73
Calls
26 calls:
Slowest
399.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
353.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
209.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))))))
125.0ms
(- (* 2 b_2) (* 1/2 (/ (* a c) b_2)))
114.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune737.0ms

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 4.9b

localize18.0ms

Local error

Found 4 expressions with local error:

23.0b
(sqrt (- (* b_2 b_2) (* a c)))
10.2b
(/ (* a c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))
3.5b
(* (/ -1 a) (/ (* a c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
1.2b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)

rewrite52.0ms

Algorithm
rewrite-expression-head
Rules
13×add-sqr-sqrt
12×add-cube-cbrt
12×*-un-lft-identity
11×add-exp-log
11×add-cbrt-cube
associate-*r*
sqrt-prod
times-frac
fma-def
pow1
add-log-exp
log1p-expm1-u
associate-/r/
associate-*l*
expm1-log1p-u
div-inv
flip-+
flip3-+
associate-/r*
cbrt-unprod
prod-exp
div-exp
sqrt-div
cbrt-undiv
associate-/l*
flip--
*-commutative
associate-*r/
associate-*l/
pow-prod-down
pow1/2
flip3--
frac-2neg
clear-num
rem-sqrt-square
+-commutative
frac-times
Counts
4 → 88
Calls
4 calls:
Slowest
16.0ms
(/ (* a c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))
15.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
14.0ms
(* (/ -1 a) (/ (* a c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
6.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series389.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
158.0ms
(/ (* a c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))
142.0ms
(* (/ -1 a) (/ (* a c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
48.0ms
(sqrt (- (* b_2 b_2) (* a c)))
40.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)

simplify3.5s

Counts
56 → 100
Calls
56 calls:
Slowest
389.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)))
389.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
383.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)))
364.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
289.0ms
(+ (log (/ -1 a)) (- (log (* a c)) (log (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))))

prune990.0ms

Pruning

8 alts after pruning (6 fresh and 2 done)

Merged error: 4.9b

regimes289.0ms

Accuracy

95.3% (1.1b remaining)

Error of 6.8b against oracle of 5.6b and baseline of 29.6b

bsearch329.0ms

end0.0ms

sample3.7s

Algorithm
intervals
Results
11497×(pre true 80)
5928×(body real 80)
2743×(body nan 80)
1015×(body real 2560)
886×(body real 1280)
456×(body real 640)
225×(body real 320)
126×(body real 160)
118×(body real 5120)