From Learning math@21:1/5 to All on Fri Mar 8 23:24:35 2024
While playing with numerical integration I arrived at a general formula for
a numerical integral as follows.
Start with the simple function such as y = x^2 and integrate it from 0 to 5
in 5 steps.
At each step the area between the curve and the x axis is approximated by a rectangle.
This will obviously give an over estimate.
I can write it as:
(5/5)*(1/((5/5)^2))*((1^2)+(2^2)+(3^2)+(4^2)+(5^2) = 55 which is higher than the exact answer of 41+2/3 as expected.
If I do the same with 10 steps I can write it as (5/10)*(1/((10/5)^2))*(1^2+2^2+3^2+4^2+5^2+6^2+7^2+8^2+9^2+10^2) = 48.125 a
bit closer
For 1000 steps I can put the following in Wolfram and get 41.7292 (5/1000)*(1/(1000/5)^2) * sum from n = 1 to 1000 of n^2
For n steps I have (5/n)*(1/((n/5)^2)) * the sum of the squares from 1 to n
More generally integrating x^2 from 0 to X instead of 0 to 5 I have, for n steps
(X/n)*(1/((n/X)^2)) * the sum of the squares from 1 to n
Even more generally for f(x) instead of x^2 it seems to be the case that the integral is
(X/n)*(1/(f(n/X)) * the sum of f(x) for x = 1 to n
n must be an integer but if I set n = X * k I can choose k to make n an interger.
Then I have the following general formula for the integral of f(x) from 0 to
X
Integral from 0 to X of f(x) is approximately (1/(k*f(k)) * the sum of f(x)
for x = 1 to n
Where n = X*k so first choose the number of steps n and then k = n/X
So if I want the integral from 0 to 4 of x^3 (which is exactly 64) I could
do it in 1000 steps by putting this in Wolfram
(1/((1000/4)*((1000/4)^3)) * the sum of x^3 for x = 1 to 1000
My guess is that this method can't be generalized to functions other than
x^n or can it?
I've never seen it used anywhere else, probably because it's not of great interest.