Average Error: 34.4 → 31.1
Time: 54.7s
Precision: 64
Internal Precision: 128
\[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}\]
\[\begin{array}{l} \mathbf{if}\;g \le 1.5669126099002344 \cdot 10^{-180}:\\ \;\;\;\;\frac{\sqrt[3]{\left(\sqrt[3]{\sqrt{\left(h + g\right) \cdot \left(g - h\right)}} \cdot \sqrt[3]{\sqrt{\left(h + g\right) \cdot \left(g - h\right)}}\right) \cdot \sqrt[3]{\sqrt{\left(h + g\right) \cdot \left(g - h\right)}} - g}}{\sqrt[3]{a \cdot 2}} + \sqrt[3]{\frac{1}{a \cdot 2} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{\frac{1}{2}}{a}} \cdot \sqrt[3]{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}} + \frac{\sqrt[3]{h \cdot h}}{\sqrt[3]{\left(a \cdot 2\right) \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}}\\ \end{array}\]

Error

Bits error versus g

Bits error versus h

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if g < 1.5669126099002344e-180

    1. Initial program 34.8

      \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}\]
    2. Using strategy rm
    3. Applied associate-*l/34.8

      \[\leadsto \sqrt[3]{\color{blue}{\frac{1 \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)}{2 \cdot a}}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}\]
    4. Applied cbrt-div31.5

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1 \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)}}{\sqrt[3]{2 \cdot a}}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}\]
    5. Simplified31.5

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\sqrt{\left(g + h\right) \cdot \left(g - h\right)} - g}}}{\sqrt[3]{2 \cdot a}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt31.5

      \[\leadsto \frac{\sqrt[3]{\color{blue}{\left(\sqrt[3]{\sqrt{\left(g + h\right) \cdot \left(g - h\right)}} \cdot \sqrt[3]{\sqrt{\left(g + h\right) \cdot \left(g - h\right)}}\right) \cdot \sqrt[3]{\sqrt{\left(g + h\right) \cdot \left(g - h\right)}}} - g}}{\sqrt[3]{2 \cdot a}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}\]

    if 1.5669126099002344e-180 < g

    1. Initial program 33.9

      \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}\]
    2. Using strategy rm
    3. Applied cbrt-prod30.2

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \color{blue}{\sqrt[3]{\frac{1}{2 \cdot a}} \cdot \sqrt[3]{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}}}\]
    4. Simplified30.2

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \color{blue}{\sqrt[3]{\frac{\frac{1}{2}}{a}}} \cdot \sqrt[3]{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}}\]
    5. Using strategy rm
    6. Applied flip-+30.1

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \cdot \color{blue}{\frac{\left(-g\right) \cdot \left(-g\right) - \sqrt{g \cdot g - h \cdot h} \cdot \sqrt{g \cdot g - h \cdot h}}{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}}}} + \sqrt[3]{\frac{\frac{1}{2}}{a}} \cdot \sqrt[3]{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}}\]
    7. Applied frac-times31.2

      \[\leadsto \sqrt[3]{\color{blue}{\frac{1 \cdot \left(\left(-g\right) \cdot \left(-g\right) - \sqrt{g \cdot g - h \cdot h} \cdot \sqrt{g \cdot g - h \cdot h}\right)}{\left(2 \cdot a\right) \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}}} + \sqrt[3]{\frac{\frac{1}{2}}{a}} \cdot \sqrt[3]{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}}\]
    8. Applied cbrt-div31.2

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1 \cdot \left(\left(-g\right) \cdot \left(-g\right) - \sqrt{g \cdot g - h \cdot h} \cdot \sqrt{g \cdot g - h \cdot h}\right)}}{\sqrt[3]{\left(2 \cdot a\right) \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}}} + \sqrt[3]{\frac{\frac{1}{2}}{a}} \cdot \sqrt[3]{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}}\]
    9. Simplified30.6

      \[\leadsto \frac{\color{blue}{\sqrt[3]{h \cdot h}}}{\sqrt[3]{\left(2 \cdot a\right) \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}} + \sqrt[3]{\frac{\frac{1}{2}}{a}} \cdot \sqrt[3]{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification31.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;g \le 1.5669126099002344 \cdot 10^{-180}:\\ \;\;\;\;\frac{\sqrt[3]{\left(\sqrt[3]{\sqrt{\left(h + g\right) \cdot \left(g - h\right)}} \cdot \sqrt[3]{\sqrt{\left(h + g\right) \cdot \left(g - h\right)}}\right) \cdot \sqrt[3]{\sqrt{\left(h + g\right) \cdot \left(g - h\right)}} - g}}{\sqrt[3]{a \cdot 2}} + \sqrt[3]{\frac{1}{a \cdot 2} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{\frac{1}{2}}{a}} \cdot \sqrt[3]{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}} + \frac{\sqrt[3]{h \cdot h}}{\sqrt[3]{\left(a \cdot 2\right) \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019010 +o rules:numerics
(FPCore (g h a)
  :name "2-ancestry mixing, positive discriminant"
  (+ (cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h)))))) (cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))))

Details

Time bar (total: 50.9s)Debug log

sample716.0ms

Algorithm
intervals

simplify384.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
383.0ms
(+ (cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h)))))) (cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h)))))))

prune36.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 36.8b

localize88.0ms

Local error

Found 4 expressions with local error:

31.8b
(sqrt (- (* g g) (* h h)))
31.8b
(sqrt (- (* g g) (* h h)))
9.3b
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
8.3b
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))

rewrite41.0ms

Algorithm
rewrite-expression-head
Rules
10×cbrt-div
sqrt-prod
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
add-log-exp
flip--
log1p-expm1-u
add-exp-log
associate-*r/
sqrt-div
add-cbrt-cube
flip3--
pow1
frac-times
expm1-log1p-u
difference-of-squares
flip-+
associate-*l/
pow1/3
pow1/2
flip3-+
rem-sqrt-square
cbrt-prod
Counts
4 → 66
Calls
4 calls:
Slowest
15.0ms
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))
14.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
6.0ms
(sqrt (- (* g g) (* h h)))
6.0ms
(sqrt (- (* g g) (* h h)))

series651.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
297.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
289.0ms
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))
37.0ms
(sqrt (- (* g g) (* h h)))
28.0ms
(sqrt (- (* g g) (* h h)))

simplify5.5s

Counts
38 → 78
Calls
38 calls:
Slowest
549.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
541.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
364.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))
349.0ms
(* (exp (* 1/3 (- (+ (log (/ -1 g)) (+ (log 1/2) (log (/ -1 a)))) (* 2 (log (/ -1 h)))))) (cbrt -1/2))
338.0ms
(cbrt (* (/ 1 (* 2 a)) (- (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))

prune1.5s

Pruning

16 alts after pruning (16 fresh and 0 done)

Merged error: 31.7b

localize31.0ms

Local error

Found 4 expressions with local error:

31.8b
(sqrt (- (* g g) (* h h)))
31.8b
(sqrt (- (* g g) (* h h)))
9.3b
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
3.0b
(- (* g g) (* h h))

rewrite31.0ms

Algorithm
rewrite-expression-head
Rules
sqrt-prod
add-sqr-sqrt
add-log-exp
add-cube-cbrt
*-un-lft-identity
cbrt-div
log1p-expm1-u
add-exp-log
sqrt-div
add-cbrt-cube
pow1
expm1-log1p-u
difference-of-squares
flip--
flip3--
flip-+
associate-*r/
pow1/2
flip3-+
rem-sqrt-square
frac-times
associate-*l/
prod-diff
diff-log
pow1/3
fma-neg
sub-neg
cbrt-prod
Counts
4 → 67
Calls
4 calls:
Slowest
14.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
6.0ms
(sqrt (- (* g g) (* h h)))
6.0ms
(sqrt (- (* g g) (* h h)))
4.0ms
(- (* g g) (* h h))

series375.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
279.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
41.0ms
(sqrt (- (* g g) (* h h)))
38.0ms
(sqrt (- (* g g) (* h h)))
16.0ms
(- (* g g) (* h h))

simplify3.5s

Counts
37 → 79
Calls
37 calls:
Slowest
580.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
367.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))
324.0ms
(cbrt (* 1 (+ (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))
247.0ms
(* (cbrt 1/2) (exp (* 1/3 (- (+ (log (/ 1 a)) (+ (log (/ 1 g)) (log -1/2))) (* 2 (log (/ 1 h)))))))
232.0ms
(sqrt (- (pow (* g g) 3) (pow (* h h) 3)))

prune1.6s

Pruning

18 alts after pruning (18 fresh and 0 done)

Merged error: 31.0b

localize50.0ms

Local error

Found 4 expressions with local error:

31.8b
(sqrt (* (+ g h) (- g h)))
31.8b
(sqrt (- (* g g) (* h h)))
9.3b
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
3.0b
(- (* g g) (* h h))

rewrite30.0ms

Algorithm
rewrite-expression-head
Rules
10×sqrt-div
add-log-exp
frac-times
add-sqr-sqrt
flip--
flip-+
sqrt-prod
add-cube-cbrt
flip3--
flip3-+
*-un-lft-identity
cbrt-div
log1p-expm1-u
add-exp-log
associate-*r/
add-cbrt-cube
pow1
expm1-log1p-u
associate-*l/
difference-of-squares
pow1/2
prod-diff
diff-log
pow1/3
fma-neg
sub-neg
rem-sqrt-square
cbrt-prod
Counts
4 → 69
Calls
4 calls:
Slowest
14.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
6.0ms
(sqrt (- (* g g) (* h h)))
5.0ms
(sqrt (* (+ g h) (- g h)))
4.0ms
(- (* g g) (* h h))

series374.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
283.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
44.0ms
(sqrt (* (+ g h) (- g h)))
25.0ms
(sqrt (- (* g g) (* h h)))
21.0ms
(- (* g g) (* h h))

simplify4.7s

Counts
39 → 81
Calls
39 calls:
Slowest
597.0ms
(sqrt (* (+ g h) (- (* g g) (* h h))))
572.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
364.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))
351.0ms
(sqrt (* (+ (pow g 3) (pow h 3)) (- (pow g 3) (pow h 3))))
319.0ms
(sqrt (* (+ g h) (- (pow g 3) (pow h 3))))

prune1.6s

Pruning

21 alts after pruning (21 fresh and 0 done)

Merged error: 31.0b

localize14.0ms

Local error

Found 4 expressions with local error:

31.8b
(sqrt (* (+ g h) (- g h)))
31.8b
(sqrt (- (* g g) (* h h)))
8.3b
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))
3.0b
(- (* g g) (* h h))

rewrite27.0ms

Algorithm
rewrite-expression-head
Rules
10×sqrt-div
flip--
flip3--
add-log-exp
frac-times
add-sqr-sqrt
sqrt-prod
add-cube-cbrt
*-un-lft-identity
cbrt-div
log1p-expm1-u
add-exp-log
associate-*r/
add-cbrt-cube
pow1
expm1-log1p-u
flip-+
associate-*l/
flip3-+
difference-of-squares
pow1/2
prod-diff
diff-log
pow1/3
fma-neg
sub-neg
rem-sqrt-square
cbrt-prod
Counts
4 → 69
Calls
4 calls:
Slowest
15.0ms
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))
4.0ms
(- (* g g) (* h h))
3.0ms
(sqrt (- (* g g) (* h h)))
3.0ms
(sqrt (* (+ g h) (- g h)))

series398.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
288.0ms
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))
47.0ms
(sqrt (* (+ g h) (- g h)))
38.0ms
(sqrt (- (* g g) (* h h)))
25.0ms
(- (* g g) (* h h))

simplify5.3s

Counts
39 → 81
Calls
39 calls:
Slowest
683.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
628.0ms
(sqrt (* (+ g h) (- (pow g 3) (pow h 3))))
563.0ms
(sqrt (* (+ g h) (- (* g g) (* h h))))
377.0ms
(sqrt (* (+ (pow g 3) (pow h 3)) (- (pow g 3) (pow h 3))))
337.0ms
(cbrt (* (/ 1 (* 2 a)) (- (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))

prune1.5s

Pruning

23 alts after pruning (23 fresh and 0 done)

Merged error: 30.9b

regimes1.8s

Accuracy

42.9% (2.1b remaining)

Error of 31.1b against oracle of 29.0b and baseline of 32.6b

bsearch1.5s

end0.0ms

sample19.1s

Algorithm
intervals