First off, why do you think you got it wrong? It’s very useful to add what kind of errors or unexpected results you already found and it makes it easier for other people to help.
Second, I think the outer_function is missing multiplication by exp(-x) like so
Also note that for performance (if it matters), you generally want to set a tolerance for both integrals and use a stricter tolerance for the inner integral by a factor of ~10 to make sure that the outer integral doesn’t try to shape the inter integral.