Let $P_{n}$ be the set of polynomials of degree $n$. Then if $f \in P_{2n + 1}$ we can compute $$\int_{-1}^1 f(x) dx$$ precisely using $n$-point Gauss-Legendre quadrature. I am interested in computing $$\log \int_{-1}^1 \exp [ \, f(x) \, ] dx$$where $f$ is a polynomial of known degree. (Actually an even polynomial in my case.) I'm hoping to compute this very precisely—i.e., I'd ideally like to recover the true answer up to machine precision.
I'm not an expert in this area, but my understanding is that the second integral is much harder to compute than the first.
Indeed, the simple case where $f(x) = -x^2$ is closely related to computing the log erf function, which is non-trivial.
Numerical approximation schemes to the erf function seem diverse and complex to my untrained eye.
Are there any general principles for numerically computing the second integral above? Do any of the classic numerical techniques for the first integral extend to the second case?
Similar question: How to numerically integrate expression using its log transform
Edit: One obvious approach is to set $g(x) = exp(x)$ and then do Gauss-Legendre quadrature on $g(x)$ and take the logarithm of the result. My thought was that this would be numerically unstable for higher order polynomials. But maybe this can work just fine?