Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Bug introduced in 9.0.0 and persisting through 10.2.0

I am trying to speed up a function that involves continued fractions. Since ContinuedFraction cannot be compiled and the alternative way with Nestlist of FractionalPart does not produce the same results due to ContinuedFraction's internal algorithm for the choice of the number of terms, I think the best way is to compute the continued fractions and then pass the integer list to the compiled function. Here's what I did:

fc = Compile[{{z, _Real}, {xcf, _Integer, 1}}, 
  Fold[z/(#1 + #2) &, 0, 1/xcf]/z, RuntimeAttributes -> Listable]
z = {-.5, .5}
xcf = Reverse /@ Rest /@ ContinuedFraction[{.123455, .546452}]
fc[z, xcf]

This approach should work, however on my computer (Mathematica 10.0.2, Xubuntu 15.04) evaluating the compiled function over a list of arguments always crashes the kernel and sometimes displays this message:

No more memory available.
Mathematica kernel has shut down.
Try quitting other applications and then retry.

Why doesn't it work and how to fix this?

By the way, I am trying to recreate a higher quality version of the "Road to the Horizon" transformation of continued fractions from Linas Vepstas' math art gallery.

Update: Setting Parallelization -> False in the compiled function as per @Joel Klein's answer in 17971, it works, and it seems this is a confirmed bug. However, in my case it does not seem to be fixed as reported in that thread.

share|improve this question
FWIW, it also crashes on Mathematica 9.0.1, but not on 8.0.4. –  Oleksandr R. Aug 7 at 10:53
I can also confirm it crashes with Mathematica 10.2. –  shrx Aug 7 at 11:59
Bug reported internally. Thank you! –  ilian Aug 7 at 15:22
@shrx 9.0.0 is correct. I checked before making my edit. –  ilian Aug 7 at 16:33
Fixed in the development version. –  ilian Aug 11 at 15:16

1 Answer 1

This bug was speedily confirmed...

Bug reported internally. Thank you! – ilian Aug 7 at 15:22

and fixed...internally at least

Fixed in the development version. – ilian Aug 11 at 15:16

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.