c3d / db48x

RPL runtime for the DM42 calculator, in the spirit of HP48/49/50
http://48calc.org
GNU Lesser General Public License v3.0
82 stars 10 forks source link

Instability or difficulty for some equivalent numerical integrals. #1188

Open Wiljea opened 1 week ago

Wiljea commented 1 week ago

If I work in terms of frequency (represented here by x) the normalised integrals: '15/π^4*∫(a;b;X^3/EXPM1(X);X)' for a = 0.001 and b = 1000 (to cover 0 to ∞) = 0.99999 99999 on both db48x & HP-Prime or for a = 0.001 and b = 10000 = 1.00004 86037 on db48x = 0.99999 99999 on HP=Prime which remains satisfactory. And otherwise for finite limits (say a = 4, b = 9) almost if not the same answers are obtained, (namely 0.38336 04817).

The problem may arise when I work in wavelength (and it seems that might be unavoidable, but I'm not absolutely positive on that requirement, I'm still trying to avoid but ...) through the change of variables y = 1/x, the mathematically equivalent integral becomes: '15/π^4*∫(1/b;1/a;Y^-5/EXPM1(1/Y);Y)' again for finite a and b, results are comparable, but not for extreme ends : for a = 0.001 and b = 1000: = 0.97090 85915 on db48x =0.99999 99999 on HP-Prime and a lot worst for a = 0.001 and b = 10 000 = 0.08304 97176 on db48x (0.00012 24913 with b = 100 000) = 0.99999 99999 on HP-Prime

NOTE The rendering of integrals is nice with numerical values for the limits a & b, but if a simple operation has to be performed, the correct rendering appears only with the function SHOW and not on the stack. This not a real problem. For instance: '15/π^4*∫(1/9;1/4;Y^-5/EXPM1(1/Y);Y)'

c3d commented 1 week ago

I'll try these same operations with the HP48 and HP50.

As I pointed out in a recent email, some progress has been made with respect to numerical integration since the HP48, and we may be able to select a more precise, if slower algorithm.

Regarding the graphical rendering of equations, it falls back to non-graphical rendering when the equation does not fit on screen. In that case, you can indeed use the SHOW function to show more, because that allows you to scroll around. With respect to the example you gave, I see two possible improvements:

  1. Render the 1/4 and 1/9 laterally instead of above/below the integral. The problem with that approach is of course if the expression expands horizontally. I hesitate to put too much "smarts" in this.

  2. Avoid rendering the parentheses around the integral, which in this specific case appear superfluous.

I also see that there is a vertical alignment issue with the dY relative to the fraction bar.