I have two functions, $f(x) = (a_0*e^{(-a_6*(x + (a_1*x + a_2)))})$ and $g(x) = abs(a_3*x^2 + a_4*x + a_5)$

I'm trying to find the integral $\int{f(x)/g(x) dx}$. Wolfram gives back :

$(a_0 exp(-1/2 (2 a_2 + ((a_1 + 1) (sqrt(a_4^2 - 4 a_3 a_5) - a_4))/a_3) a_6) (Ei(-((a_1 + 1) (2 x a_3 + a_4 - sqrt(a_4^2 - 4 a_3 a_5)) a_6)/(2 a_3)) - e^{(((a_1 + 1) sqrt(a_4^2 - 4 a_3 a_5) a_6)/a_3)} Ei(-((a_1 + 1) (2 x a_3 + a_4 + sqrt(a_4^2 - 4 a_3 a_5)) a_6)/(2 a_3))) sgn(a_3 x^2 + a_4 x + a_5))/sqrt(a_4^2 - 4 a_3 a_5) + constant$

which is a problem because of $Ei$, the exponential integral. On my platform, computing $Ei$ does not really seem feasible. AFAIK there is no "simple" approximation of $Ei(x)$.

What I might be able to do is transform some of the functions around, since they represent other concepts. For example f(x) is really just Beer's Law, and g(x) is really just an abstract representation of the area of a triangle whose points are a function of x, changing $g(x)$ to $1/4*sqrt(a_3*x^4 + a_4*x^3 + a_5*x^2 + a_6*x + a_7)$ (note I compressed constants together into these $a_n$ terms) if we use herons formula. Unfortunately plugging this into wolfram gives me nothing.

What is strange is that individually these functions seem to give perfectly normal integrals (using $1/g(x))$, and visually in what I'm trying to compute there's no transcendental-ness going on, so I'm not exactly sure what is causing the need to use $Ei$. Is there any way I can avoid having these non elementary functions in my integral, or at least only have functions that are relatively easy to compute?

Also note $x >= 0$ always, and all constants and $x$ will be real numbers.


I do not see how you could avoid the exponential integral.

Concerning its approximation, for real values of $x$, you could use the expansion $$\text{Ei}(x)=\gamma+\log (x)+\sum_{n=1}^\infty \frac {x^n}{n\, n!}$$ which converges quite fast.

If you look here, you will see that Ramanujan proposed a faster convergence expansion $${\rm Ei} (x) = \gamma + \ln x + e^{\frac x 2} \sum_{n=1}^\infty \frac{ (-1)^{n-1} x^n} {n! \, 2^{n-1}} \sum_{k=0}^{\left\lfloor \frac{n-1}{2}\right\rfloor} \frac{1}{2k+1}$$ where

$$\sum_{k=0}^{\left\lfloor \frac{n-1}{2}\right\rfloor} \frac{1}{2k+1}=\frac{1}{2} H_{\left\lfloor \frac{n-1}{2}\right\rfloor +\frac{1}{2}}+{\log (2)}$$

  • $\begingroup$ What is $H$ here? and what are the constraints under which these are accurate? Looking at wikipedia it seems they are quite limited. $\endgroup$ – opa Aug 15 at 13:16
  • $\begingroup$ @opa. $H_q$ is the harmonic number. It can be as accurate as you want. $\endgroup$ – Claude Leibovici Aug 15 at 14:11
  • $\begingroup$ Sorry, what I meant was, it looked like the approximation may diverge for certain values of $x$, which would seem to go against the notion that it can be as accurate as I want. $\endgroup$ – opa Aug 15 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.