ssmit1986 / lazyLists

Lazy Lists package for Wolfram Language
MIT License
13 stars 1 forks source link

Crashes large symbolic Wick contraction/ gaussian integration . #1

Open userrand opened 1 year ago

userrand commented 1 year ago

Thank you for this very nice code with a very nice documentation.

Short version: The kernel crashes when using intensive computations with Map and a recursive function.

Further details:

I tried using this in a symbolic calculation where I compute Wick contractions or in other words compute correlations of random variables with a Gaussian distribution.

The multivariate random distribution has a symbolic covariance matrix A[i,j].

I split a sum of 10 terms into a list of sums of 2 or 3 terms. Each sum is averaged over by multivariate Gaussian integration with a symbolic matrix covariance matrix.

A given term can involve a product of 14 random variables which can require significant computation but it works quickly (like around 3 seconds) when using normal lists on this small example.

If I use the lazyLists here rather than regular lists Mathematica crashes.

If needed I can provide the code for the Gaussian integration and the test example but the code for the Gaussian integration adapted to my notation choices is rather lengthy.

userrand commented 1 year ago

I can not seem to understand what causes this with this package. I tried with the other package in this link: https://mathematica.stackexchange.com/a/4093/86543 and it works as would be expected. I don't understand why this package crashes before converting the lazy list to a list. Only the head should have been computed which is not very memory expensive.

Maybe I should note that I do get some unexpected crashes with Mathematica 13.1 on Linux for seemingly not too difficult tasks and perhaps this is related to one of the weird crashes I get.

ssmit1986 commented 1 year ago

Hi. I just wanted to quickly respond that I was on holidays. I'll try to look into this sometime soon when the holiday backlog clears a little :)

userrand commented 1 year ago

Hello,

Ok thank you for the notice (: .

SjoerdSmitWolfram commented 1 year ago

Hmmm, well I know my code isn't ideal in all ways and maybe it over-relies on having a high $IterationLimit. Try setting lazyLists`Private`$lazyIterationLimit to some finite number and see if that at least resolves the crash.

Other than that, I'll need to see a minimal example to even begin to debug this problem.

SjoerdSmitWolfram commented 1 year ago

Oh, and I've also not really updated the main branch in a while but I have tinkered a bit. You can try checking out sjoerds/Development and loading the code from the workspace (using the code at the top of the main notebook) to see if the more recent changes are of any help.