# Tag Info

4

This integral has a closed analytic solution. The trick is to write $$\frac{1}{x^3+ ax + 2a} = \frac{A}{x-x_1} + \frac{B}{x-x_2} + \frac{C}{x-x_3}$$ by a method called partial fraction decomposition. The values $x_i$ are the roots of the polynomial in the denominator. As your polynomial only has third degree, an analytic formula for the roots exists (aka "...

3

Yes, it is very well arguable that $\frac{e^x-1}{x}$ is as right as'' expm1. It appears frequently in applications; see for instance Sections 2.1 and 10.7.4 of Higham's Function of Matrices, which mention exponential integrators and matrix functions; this function is called $\psi_1(x)$ there. Your example, integrating exponentials, is another one, and it ...

2

expm1 is a primitive because for small $x$, the Taylor series for $e^x=1+x+x^2+\cdots$ adds small terms to one -- which implies that if $x$ is small enough, you lose almost all digits of accuracy other than the leading one and so the expression $e^x-1$ can not be accurately computed by first evaluating the exponential. The fact that you happen to have an ...

1

In essence, you are asking whether you have values for a function $h'(r)$ at points $r_i$, you can obtain an approximation of $h(r)$. The answer is of course yes: If you connect the points $(r_i,h'(r_i))$ by a piecewise linear curve, then you can integrate that to obtain a piecewise quadratic approximation of $h(r)$. You can be more accurate if you connect ...

1

Please have a look at the answers to this question on CrossValidated. There you can find a worked out solution (including R-code) based on Gauss-Hermite quadrature, which is especially designed for this problem (note that it requires a variable transformation) and -in a different answer- a comparsion of MonteCarlo (slow) with the R builtin function integrate ...

Only top voted, non community-wiki answers of a minimum length are eligible