**TI92P*mainSingle file dated Sat Oct 21 21:04:41 20ReiZg(x)
Func
Copyright 2023 John Scott (https://johnscott.me)
This program is free software subject to the GNU General Public License as published by the Free Software Foundation, either version three of the license or, at your option, any later version.
Version 2023/10/21
Compute the exponential integral Ei(x) for real x greater than zero. Similarly to the TI-83/TI-84 Plus version, we do the integral numerically for small parameters, and use the asymptotic expansion for big parameters.
To compute the logarithmic integral which happens to be a good approximation to the prime counting function, compute ei(ln(x)).
If imag(x)0 or real(x)<0 Then
Complex parameters are not supported for this variant of the exponential integral, and they will not be unless someone asks for it. E1(z) avoids many problems of extending Ei(x) to the complex plane.
Return undef
EndIf
If x<25 Then
The asymptotic expansion won't yield enough precision, but fortunately, when we write the integral like this, numerical integration works well.
Return .577215664902+ln(x)+approx(((^t-1)/t,t,0,x))
EndIf
Now we get to use the asymptotic expansion, and we're going to use 30 terms. More are unnecessary at the precision we're working in, and the complexity of adding logic to use fewer terms when 25 < x < 30 isn't worth it.
Return ^x/x*approx((n!/x^n,n,0,30))
EndFunct@