Average Error: 34.6 → 30.8
Time: 57.6s
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.6739327644208389 \cdot 10^{-167}:\\ \;\;\;\;\sqrt[3]{\frac{\frac{1}{2}}{a}} \cdot \sqrt[3]{\frac{g \cdot g - \sqrt{g \cdot g - h \cdot h} \cdot \sqrt{g \cdot g - h \cdot h}}{\sqrt{g \cdot g - h \cdot h} + \left(-g\right)}} + \frac{\sqrt[3]{\sqrt{\left(h + g\right) \cdot \left(g - h\right)} - g}}{\sqrt[3]{2 \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\left(-g\right) - g} \cdot \sqrt[3]{\frac{\frac{1}{2}}{a}} + \sqrt[3]{\left(\sqrt{g \cdot g - h \cdot h} + \left(-g\right)\right) \cdot \frac{1}{2 \cdot a}}\\ \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.6739327644208389e-167

    1. Initial program 33.2

      \[\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-prod33.1

      \[\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. Simplified33.1

      \[\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 associate-*l/33.1

      \[\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{\frac{1}{2}}{a}} \cdot \sqrt[3]{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}}\]
    7. Applied cbrt-div29.6

      \[\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{\frac{1}{2}}{a}} \cdot \sqrt[3]{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}}\]
    8. Simplified29.6

      \[\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{\frac{1}{2}}{a}} \cdot \sqrt[3]{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}}\]
    9. Using strategy rm
    10. Applied flip--29.4

      \[\leadsto \frac{\sqrt[3]{\sqrt{\left(g + h\right) \cdot \left(g - h\right)} - g}}{\sqrt[3]{2 \cdot a}} + \sqrt[3]{\frac{\frac{1}{2}}{a}} \cdot \sqrt[3]{\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}}}}\]

    if -1.6739327644208389e-167 < g

    1. Initial program 35.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-prod32.5

      \[\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. Simplified32.5

      \[\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. Taylor expanded around inf 32.1

      \[\leadsto \sqrt[3]{\frac{1}{2 \cdot a} \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) - \color{blue}{g}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification30.8

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

Reproduce

herbie shell --seed 2019022 +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: 54.2s)Debug log

sample504.0ms

Algorithm
intervals
Results
132.0ms739×body80nan
122.0ms33×body5120valid
103.0ms86×body2560valid
68.0ms53×body1280valid
25.0ms29×body640valid
13.0ms25×body320valid
10.0ms25×body160valid
1.0msbody80valid

simplify686.0ms

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

prune27.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 34.1b

localize42.0ms

Local error

Found 4 expressions with local error:

30.6b
(sqrt (- (* g g) (* h h)))
30.6b
(sqrt (- (* g g) (* h h)))
9.6b
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))
7.5b
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))

rewrite32.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
13.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
12.0ms
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))
3.0ms
(sqrt (- (* g g) (* h h)))
3.0ms
(sqrt (- (* g g) (* h h)))

series647.0ms

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

simplify5.4s

Counts
38 → 78
Calls
38 calls:
Slowest
552.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
523.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
353.0ms
(* (exp (* 1/3 (- (+ (log (/ -1 g)) (+ (log 1/2) (log (/ -1 a)))) (* 2 (log (/ -1 h)))))) (cbrt -1/2))
343.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))
314.0ms
(* (exp (* 1/3 (- (+ (log 2) (log (/ 1 a))) (log (/ 1 g))))) (cbrt -1/2))

prune1.3s

Pruning

17 alts after pruning (17 fresh and 0 done)

Merged error: 30.5b

localize28.0ms

Local error

Found 4 expressions with local error:

30.6b
(sqrt (- (* g g) (* h h)))
30.6b
(sqrt (- (* g g) (* h h)))
7.5b
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
4.2b
(- (* g g) (* h h))

rewrite15.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
7.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
3.0ms
(sqrt (- (* g g) (* h h)))
3.0ms
(sqrt (- (* g g) (* h h)))
2.0ms
(- (* g g) (* h h))

series359.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
286.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
33.0ms
(sqrt (- (* g g) (* h h)))
24.0ms
(sqrt (- (* g g) (* h h)))
16.0ms
(- (* g g) (* h h))

simplify3.1s

Counts
37 → 79
Calls
37 calls:
Slowest
557.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
375.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))
229.0ms
(cbrt (* 1 (+ (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))
219.0ms
(sqrt (- (pow (* g g) 3) (pow (* h h) 3)))
202.0ms
(cbrt (* 1 (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))

prune1.6s

Pruning

19 alts after pruning (19 fresh and 0 done)

Merged error: 29.9b

localize28.0ms

Local error

Found 4 expressions with local error:

30.6b
(sqrt (* (+ g h) (- g h)))
30.6b
(sqrt (- (* g g) (* h h)))
4.2b
(- (* g g) (* h h))
3.3b
(- (- g) (sqrt (- (* g g) (* h h))))

rewrite16.0ms

Algorithm
rewrite-expression-head
Rules
29×prod-diff
26×add-sqr-sqrt
23×*-un-lft-identity
22×sqrt-prod
21×add-cube-cbrt
10×sqrt-div
difference-of-squares
add-log-exp
neg-mul-1
flip--
flip3--
fma-neg
log1p-expm1-u
add-exp-log
add-cbrt-cube
pow1
frac-times
expm1-log1p-u
flip-+
flip3-+
associate-*r/
associate-*l/
diff-log
pow1/2
sub-neg
distribute-lft-out--
rem-sqrt-square
neg-sub0
associate--l-
Counts
4 → 103
Calls
4 calls:
Slowest
7.0ms
(- (- g) (sqrt (- (* g g) (* h h))))
3.0ms
(sqrt (- (* g g) (* h h)))
2.0ms
(sqrt (* (+ g h) (- g h)))
2.0ms
(- (* g g) (* h h))

series132.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
42.0ms
(- (- g) (sqrt (- (* g g) (* h h))))
40.0ms
(sqrt (* (+ g h) (- g h)))
34.0ms
(sqrt (- (* g g) (* h h)))
16.0ms
(- (* g g) (* h h))

simplify9.2s

Counts
97 → 115
Calls
97 calls:
Slowest
545.0ms
(sqrt (* (+ g h) (- (* g g) (* h h))))
337.0ms
(sqrt (* (+ (pow g 3) (pow h 3)) (- (pow g 3) (pow h 3))))
282.0ms
(sqrt (* (+ g h) (- (pow g 3) (pow h 3))))
212.0ms
(sqrt (* (- (* g g) (* h h)) (- (pow g 3) (pow h 3))))
197.0ms
(fma 1 (- g) (- (* (sqrt (- (* g g) (* h h))) (sqrt 1))))

prune2.5s

Pruning

20 alts after pruning (20 fresh and 0 done)

Merged error: 29.9b

localize13.0ms

Local error

Found 4 expressions with local error:

30.6b
(sqrt (* (+ g h) (- g h)))
30.6b
(sqrt (- (* g g) (* h h)))
7.5b
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
4.2b
(- (* g g) (* h h))

rewrite16.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
7.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
3.0ms
(sqrt (- (* g g) (* h h)))
3.0ms
(sqrt (* (+ g h) (- g h)))
2.0ms
(- (* g g) (* h h))

series385.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
296.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
40.0ms
(sqrt (* (+ g h) (- g h)))
26.0ms
(sqrt (- (* g g) (* h h)))
22.0ms
(- (* g g) (* h h))

simplify4.9s

Counts
39 → 81
Calls
39 calls:
Slowest
872.0ms
(sqrt (* (+ g h) (- (* g g) (* h h))))
520.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
364.0ms
(sqrt (* (+ (pow g 3) (pow h 3)) (- (pow g 3) (pow h 3))))
354.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))
277.0ms
(cbrt (* 1 (+ (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))

prune1.6s

Pruning

22 alts after pruning (22 fresh and 0 done)

Merged error: 29.9b

regimes1.6s

Accuracy

67.5% (1.4b remaining)

Error of 30.8b against oracle of 29.4b and baseline of 33.7b

bsearch798.0ms

end0.0ms

sample19.3s

Algorithm
intervals
Results
6.5s23779×body80nan
5.1s2639×body2560valid
3.0s1928×body1280valid
2.4s1174×body5120valid
964.0ms1074×body640valid
398.0ms599×body320valid
253.0ms427×body160valid
32.0ms159×body80valid