Choosing order in QuadGK

Anybody has a rough idea how I should set the order of QuadGK for a standard mass matrix element calculation (Lagrange element) with order p^2 and BigFloat precision N

i read this in documentation:

It is advisable to increase the integration order in rough proportion to the precision, for smooth integrands.

and it is not very clear so me. Say I want p=20 and N=1000, then what order for the quadrature should I set?

And yes, I need these kinds of matrices. It is not for FEM calculations. Doing it symbolically would be ok too if somebody has some hints.

Is your question for a given N, how to choose p? Otherwise I don’t understand the question. For a smooth integrand (technically, it depends on the region of analyticity), you can expect that the error of a Lagrange interpolation with p points behaves as exp(-c p) where c is a constant. Therefore, if you find out that a given p gives you N digits, you should use 2p to give you 2N digits.

Bad choice of notation from my part N here is the precision of BigFloat in bits, I need to do many different runs with varying number of bits, some over 3000 bits. I need to do for varying order of the Lagrange polynomials (up to maybe p=50, doing up to 20 now). Code works fine but already at p=7 it is very slow. We are talking about 12 hours for a tiny matrix (mixing up questions now, ignore the size of the matrix, here I am talking about the specific elements for assembly, in other parts of the code I am computing the eigenvalues which is of course not related) maybe 256 bit precision and p=10. In documentation of QuadGK
It states that one should increase the integration order of QuadGK with precision. I am not setting it to anything at the moment and letting it choose by itself.

So my question is: For a given p and N, what would be an appropriate argument order=x to the function quadgk to make it faster, I assume it is slow because it is adaptively increasing this order. I could always try but since one run is about 12h it is a bit awkward :slight_smile: