Average Error: 33.0 → 6.4
Time: 27.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 -6.952882728129189 \cdot 10^{+102}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le -3.033451162286551 \cdot 10^{-263}:\\ \;\;\;\;\frac{1}{a} \cdot \left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right)\\ \mathbf{elif}\;b_2 \le 2.1436459426001753 \cdot 10^{+111}:\\ \;\;\;\;\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 < -6.952882728129189e+102

    1. Initial program 44.6

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

      \[\leadsto \color{blue}{\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 -6.952882728129189e+102 < b_2 < -3.033451162286551e-263

    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. Using strategy rm
    4. Applied div-inv8.5

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

    if -3.033451162286551e-263 < b_2 < 2.1436459426001753e+111

    1. Initial program 30.3

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

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

      \[\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/34.9

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

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

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

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

    if 2.1436459426001753e+111 < b_2

    1. Initial program 59.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -6.952882728129189 \cdot 10^{+102}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le -3.033451162286551 \cdot 10^{-263}:\\ \;\;\;\;\frac{1}{a} \cdot \left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right)\\ \mathbf{elif}\;b_2 \le 2.1436459426001753 \cdot 10^{+111}:\\ \;\;\;\;\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 1042149663 
(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: 25.3s)Debug log

sample192.0ms

Algorithm
intervals
Results
369×(pre true 80)
181×(body real 80)
88×(body nan 80)
31×(body real 1280)
28×(body real 2560)
22×(body real 640)
13×(body real 320)
(body real 160)
(body real 5120)

simplify42.0ms

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

prune44.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 34.2b

localize45.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.8b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)

rewrite80.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
46.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
24.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
5.0ms
(sqrt (- (* b_2 b_2) (* a c)))
4.0ms
(- (* b_2 b_2) (* a c))

series299.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
101.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
79.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
77.0ms
(sqrt (- (* b_2 b_2) (* a c)))
41.0ms
(- (* b_2 b_2) (* a c))

simplify2.1s

Counts
24 → 65
Calls
24 calls:
Slowest
412.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
406.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))
386.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
190.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
163.0ms
(- (pow (sqrt (- (* b_2 b_2) (* a c))) 3) (pow b_2 3))

prune1.1s

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 5.5b

localize31.0ms

Local error

Found 4 expressions with local error:

21.8b
(sqrt (- (* b_2 b_2) (* a c)))
17.9b
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
0.8b
(- (* b_2 b_2) (* a c))
0.4b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)

rewrite49.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
add-log-exp
associate-/l*
add-exp-log
add-cbrt-cube
times-frac
pow1
sqrt-prod
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
div-exp
div-sub
diff-log
pow1/2
frac-2neg
sub-neg
associate-/r*
clear-num
rem-sqrt-square
+-commutative
cbrt-undiv
neg-sub0
Counts
4 → 65
Calls
4 calls:
Slowest
21.0ms
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
18.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
5.0ms
(sqrt (- (* b_2 b_2) (* a c)))
4.0ms
(- (* b_2 b_2) (* a c))

series421.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
210.0ms
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
85.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
74.0ms
(sqrt (- (* b_2 b_2) (* a c)))
52.0ms
(- (* b_2 b_2) (* a c))

simplify3.6s

Counts
41 → 77
Calls
41 calls:
Slowest
639.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))))
467.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
418.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
403.0ms
(- (log (- (* a c))) (log (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))))
323.0ms
(/ (* a c) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))

prune1.2s

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 5.4b

localize21.0ms

Local error

Found 4 expressions with local error:

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

rewrite16.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
sqrt-prod
associate-/r*
flip--
flip-+
associate-/r/
sqrt-div
flip3--
flip3-+
div-inv
diff-log
pow1/2
frac-2neg
sub-neg
clear-num
rem-sqrt-square
+-commutative
Counts
4 → 51
Calls
4 calls:
Slowest
5.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)))))

series393.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
200.0ms
(/ c (+ b_2 (sqrt (- (* b_2 b_2) (* a c)))))
82.0ms
(+ b_2 (sqrt (- (* b_2 b_2) (* a c))))
70.0ms
(sqrt (- (* b_2 b_2) (* a c)))
41.0ms
(- (* b_2 b_2) (* a c))

simplify1.8s

Counts
24 → 63
Calls
24 calls:
Slowest
413.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
356.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
277.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))))))
198.0ms
(- (* 2 b_2) (* 1/2 (/ (* a c) b_2)))
192.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune1.0s

Pruning

8 alts after pruning (6 fresh and 2 done)

Merged error: 5.4b

localize17.0ms

Local error

Found 4 expressions with local error:

21.8b
(sqrt (- (* b_2 b_2) (* a c)))
17.9b
(/ (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)) (* a c))
0.8b
(- (* b_2 b_2) (* a c))
0.5b
(/ -1 (/ (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)) (* a c)))

rewrite41.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-log-exp
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
associate-/r*
pow1
div-inv
sqrt-prod
associate-/l/
flip--
associate-*r/
sqrt-div
flip3--
times-frac
frac-2neg
clear-num
associate-/l*
flip-+
associate-/r/
div-exp
diff-log
pow1/2
flip3-+
sub-neg
rem-sqrt-square
cbrt-undiv
Counts
4 → 59
Calls
4 calls:
Slowest
29.0ms
(/ (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)) (* a c))
5.0ms
(sqrt (- (* b_2 b_2) (* a c)))
4.0ms
(- (* b_2 b_2) (* a c))
1.0ms
(/ -1 (/ (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)) (* a c)))

series415.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
189.0ms
(/ -1 (/ (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)) (* a c)))
115.0ms
(/ (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)) (* a c))
70.0ms
(sqrt (- (* b_2 b_2) (* a c)))
42.0ms
(- (* b_2 b_2) (* a c))

simplify4.2s

Counts
31 → 71
Calls
31 calls:
Slowest
710.0ms
(- (log (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))) (log (* a c)))
427.0ms
(* a (- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2)))
418.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
378.0ms
(/ (* (* (* 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))) (* (* (* a c) (* a c)) (* a c)))
375.0ms
(/ (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)) (* a c))

prune1.1s

Pruning

9 alts after pruning (6 fresh and 3 done)

Merged error: 5.4b

regimes421.0ms

Accuracy

95.7% (1.0b remaining)

Error of 6.4b against oracle of 5.4b and baseline of 29.1b

bsearch550.0ms

end0.0ms

sample6.0s

Algorithm
intervals
Results
11580×(pre true 80)
5842×(body real 80)
2894×(body nan 80)
1079×(body real 2560)
861×(body real 1280)
446×(body real 640)
230×(body real 320)
132×(body real 160)
96×(body real 5120)