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

    1. Initial program 36.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-prod32.8

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

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

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

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

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

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

    if 1.5852886249971206e-162 < g

    1. Initial program 32.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 cbrt-prod28.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. Simplified28.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. Using strategy rm
    6. Applied flip-+28.4

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

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

      \[\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. Simplified28.8

      \[\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 simplification30.9

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

Reproduce

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

sample606.0ms

Algorithm
intervals
Results
952×(pre true 80)
695×(body nan 80)
97×(body real 2560)
57×(body real 1280)
28×(body real 640)
27×(body real 5120)
26×(body real 320)
17×(body real 160)
(body real 80)

simplify275.0ms

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

prune30.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 33.9b

localize52.0ms

Local error

Found 4 expressions with local error:

28.9b
(sqrt (- (* g g) (* h h)))
28.9b
(sqrt (- (* g g) (* h h)))
10.3b
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
8.9b
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))

rewrite22.0ms

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

series604.0ms

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

simplify5.3s

Counts
38 → 70
Calls
38 calls:
Slowest
646.0ms
(cbrt (* 1 (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
559.0ms
(cbrt (* 1 (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
543.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
457.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
298.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))

prune1.3s

Pruning

18 alts after pruning (18 fresh and 0 done)

Merged error: 29.4b

localize29.0ms

Local error

Found 4 expressions with local error:

28.9b
(sqrt (- (* g g) (* h h)))
28.9b
(sqrt (- (* g g) (* h h)))
8.9b
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))
4.2b
(- (* g g) (* h h))

rewrite25.0ms

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

series394.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
290.0ms
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))
40.0ms
(sqrt (- (* g g) (* h h)))
35.0ms
(sqrt (- (* g g) (* h h)))
28.0ms
(- (* g g) (* h h))

simplify3.1s

Counts
35 → 69
Calls
35 calls:
Slowest
562.0ms
(cbrt (* 1 (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
327.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
309.0ms
(* (exp (* 1/3 (- (+ (log 2) (log (/ 1 a))) (log (/ 1 g))))) (cbrt -1/2))
259.0ms
(* (exp (* 1/3 (- (+ (log (/ -1 g)) (+ (log 1/2) (log (/ -1 a)))) (* 2 (log (/ -1 h)))))) (cbrt -1/2))
257.0ms
(cbrt (* (/ 1 (* 2 a)) (- (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))

prune1.3s

Pruning

21 alts after pruning (21 fresh and 0 done)

Merged error: 28.9b

localize34.0ms

Local error

Found 4 expressions with local error:

28.9b
(sqrt (* (- g h) (+ g h)))
28.9b
(sqrt (- (* g g) (* h h)))
8.9b
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))
4.2b
(- (* g g) (* h h))

rewrite31.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
add-exp-log
associate-*r/
add-cbrt-cube
pow1
flip-+
associate-*l/
flip3-+
difference-of-squares
pow1/2
diff-log
pow1/3
sub-neg
rem-sqrt-square
cbrt-prod
Counts
4 → 59
Calls
4 calls:
Slowest
21.0ms
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))
4.0ms
(sqrt (- (* g g) (* h h)))
3.0ms
(sqrt (* (- g h) (+ g h)))
2.0ms
(- (* g g) (* h h))

series351.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
259.0ms
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))
35.0ms
(sqrt (- (* g g) (* h h)))
31.0ms
(sqrt (* (- g h) (+ g h)))
26.0ms
(- (* g g) (* h h))

simplify5.1s

Counts
37 → 71
Calls
37 calls:
Slowest
787.0ms
(sqrt (* (- (* g g) (* h h)) (+ g h)))
601.0ms
(cbrt (* 1 (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
488.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
392.0ms
(* (exp (* 1/3 (- (+ (log (/ -1 g)) (+ (log 1/2) (log (/ -1 a)))) (* 2 (log (/ -1 h)))))) (cbrt -1/2))
379.0ms
(sqrt (* (- (pow g 3) (pow h 3)) (+ g h)))

prune1.4s

Pruning

22 alts after pruning (22 fresh and 0 done)

Merged error: 28.9b

localize10.0ms

Local error

Found 4 expressions with local error:

28.9b
(sqrt (- (* g g) (* h h)))
28.9b
(sqrt (- (* g g) (* h h)))
10.3b
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
4.2b
(- (* g g) (* h h))

rewrite13.0ms

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

series371.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
285.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
30.0ms
(sqrt (- (* g g) (* h h)))
29.0ms
(sqrt (- (* g g) (* h h)))
27.0ms
(- (* g g) (* h h))

simplify3.1s

Counts
35 → 69
Calls
35 calls:
Slowest
615.0ms
(cbrt (* 1 (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
422.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
322.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))
221.0ms
(cbrt (* 1 (+ (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))
171.0ms
(* (cbrt 1/2) (exp (* 1/3 (- (+ (log (/ 1 a)) (+ (log (/ 1 g)) (log -1/2))) (* 2 (log (/ 1 h)))))))

prune1.2s

Pruning

22 alts after pruning (22 fresh and 0 done)

Merged error: 28.8b

regimes1.6s

Accuracy

44.7% (2.0b remaining)

Error of 30.9b against oracle of 28.8b and baseline of 32.5b

bsearch1.7s

end0.0ms

sample19.9s

Algorithm
intervals
Results
32517×(pre true 80)
24517×(body nan 80)
2580×(body real 2560)
1981×(body real 1280)
1123×(body real 5120)
1065×(body real 640)
590×(body real 320)
502×(body real 160)
159×(body real 80)