Average Error: 34.6 → 30.4
Time: 55.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 -3.3292661184590287 \cdot 10^{-161}:\\ \;\;\;\;\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}:\\ \;\;\;\;\sqrt[3]{\left(-g\right) - g} \cdot \sqrt[3]{\frac{\frac{1}{2}}{a}} + \sqrt[3]{\left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\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 < -3.3292661184590287e-161

    1. Initial program 34.0

      \[\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.6

      \[\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. Simplified30.6

      \[\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--30.5

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

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

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

      \[\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 -3.3292661184590287e-161 < g

    1. Initial program 35.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-prod31.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. Simplified31.0

      \[\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 30.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;g \le -3.3292661184590287 \cdot 10^{-161}:\\ \;\;\;\;\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}:\\ \;\;\;\;\sqrt[3]{\left(-g\right) - g} \cdot \sqrt[3]{\frac{\frac{1}{2}}{a}} + \sqrt[3]{\left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{1}{2 \cdot a}}\\ \end{array}\]

Reproduce

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

sample603.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)

simplify378.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
378.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: 33.9b

localize43.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))))))

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

series630.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
306.0ms
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))
272.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h))))))
29.0ms
(sqrt (- (* g g) (* h h)))
24.0ms
(sqrt (- (* g g) (* h h)))

simplify5.6s

Counts
38 → 78
Calls
38 calls:
Slowest
610.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
540.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
390.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))
366.0ms
(* (exp (* 1/3 (- (+ (log (/ -1 g)) (+ (log 1/2) (log (/ -1 a)))) (* 2 (log (/ -1 h)))))) (cbrt -1/2))
352.0ms
(cbrt (* (/ 1 (* 2 a)) (- (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))

prune1.4s

Pruning

17 alts after pruning (17 fresh and 0 done)

Merged error: 29.5b

localize31.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))

rewrite23.0ms

Algorithm
rewrite-expression-head
Rules
sqrt-prod
add-sqr-sqrt
add-log-exp
add-cube-cbrt
*-un-lft-identity
flip--
flip3--
cbrt-div
log1p-expm1-u
add-exp-log
sqrt-div
add-cbrt-cube
pow1
expm1-log1p-u
difference-of-squares
associate-*r/
pow1/2
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))))))
7.0ms
(sqrt (- (* g g) (* h h)))
6.0ms
(sqrt (- (* g g) (* h h)))
2.0ms
(- (* g g) (* h h))

series387.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
304.0ms
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))
36.0ms
(sqrt (- (* g g) (* h h)))
28.0ms
(sqrt (- (* g g) (* h h)))
17.0ms
(- (* g g) (* h h))

simplify3.4s

Counts
37 → 79
Calls
37 calls:
Slowest
629.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
316.0ms
(* (exp (* 1/3 (- (+ (log (/ -1 g)) (+ (log 1/2) (log (/ -1 a)))) (* 2 (log (/ -1 h)))))) (cbrt -1/2))
288.0ms
(cbrt (* (/ 1 (* 2 a)) (- (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))
258.0ms
(* (exp (* 1/3 (- (+ (log 2) (log (/ 1 a))) (log (/ 1 g))))) (cbrt -1/2))
197.0ms
(sqrt (- (pow (* g g) 3) (pow (* h h) 3)))

prune1.7s

Pruning

20 alts after pruning (20 fresh and 0 done)

Merged error: 29.0b

localize36.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))

rewrite16.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
8.0ms
(cbrt (* (/ 1 (* 2 a)) (- (- 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))

series342.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
257.0ms
(cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))
35.0ms
(sqrt (- (* g g) (* h h)))
33.0ms
(sqrt (* (+ g h) (- g h)))
17.0ms
(- (* g g) (* h h))

simplify5.4s

Counts
39 → 81
Calls
39 calls:
Slowest
590.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
552.0ms
(sqrt (* (+ g h) (- (* g g) (* h h))))
509.0ms
(sqrt (sqrt (- (* g g) (* h h))))
364.0ms
(* (exp (* 1/3 (- (+ (log 2) (log (/ 1 a))) (log (/ 1 g))))) (cbrt -1/2))
347.0ms
(cbrt (* (/ 1 (* 2 a)) (- (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))

prune1.8s

Pruning

21 alts after pruning (21 fresh and 0 done)

Merged error: 28.9b

localize18.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))

rewrite16.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))

series388.0ms

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

simplify3.4s

Counts
37 → 79
Calls
37 calls:
Slowest
624.0ms
(cbrt (* (/ 1 (* 2 a)) (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))
325.0ms
(cbrt (* (/ 1 (* 2 a)) (+ (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))
239.0ms
(* (cbrt 1/2) (exp (* 1/3 (- (+ (log (/ 1 a)) (+ (log (/ 1 g)) (log -1/2))) (* 2 (log (/ 1 h)))))))
233.0ms
(cbrt (* 1 (+ (pow (- g) 3) (pow (sqrt (- (* g g) (* h h))) 3))))
218.0ms
(cbrt (* 1 (- (* (- g) (- g)) (* (sqrt (- (* g g) (* h h))) (sqrt (- (* g g) (* h h)))))))

prune1.5s

Pruning

21 alts after pruning (21 fresh and 0 done)

Merged error: 28.8b

regimes1.7s

Accuracy

57.2% (1.6b remaining)

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

bsearch1.8s

end0.0ms

sample21.2s

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)