|
Gauss-Legendre Quadrature of order 10 +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (https://www.hpmuseum.org/forum/forum-10.html) +--- Forum: HP Prime Software Library (https://www.hpmuseum.org/forum/forum-15.html) +--- Thread: Gauss-Legendre Quadrature of order 10 (/thread-24074.html) |
Gauss-Legendre Quadrature of order 10 - Namir - 2025-09-20 I used Claude AI to generate the code for the HP-Prime to perform Gauss-Legendre Quadrature of order 10. I then edited the code to allow you to apply the algorithm multiple times in a given integration range in order to increase the accuracy of the result. The function MYFX defines the integrated function. The function GaussQuad10 defines the integration function. It has the following parameters: 1. Parameter a is the lower integration range. 2. Parameter b is the upper integration range. 3. Parameter h is the increment value. When h is equal to b - a, the function performs the integration on the entire range (a, b). When h is smaller than (b - a), the function calculates multiple sub-integrals to yield a more accurate result. Code: // Local function to integrateExample: GaussQuad10(1,100,0.01) returns 4.605170186 compared to LN(100) = 4.60517018599 GaussQuad10(1,2,1) returns 0.69314718056 compared to LN(2) = 0.69314718056 |