Riemann Sums for exponential functions
It does not matter what the function is. The general formula are
$$ I \approx \frac{1}{n}\sum_{k=0}^{n-1} f\left(\frac{1}{k}\right)$$ using the left side of rectangles. $$ I \approx \frac{1}{n}\sum_{k=1}^{n} f\left(\frac{1}{k}\right)$$ using the right side of rectangles.
You can average the two to get Trapezoidal integration.
For your problem $$ f\left(\frac{1}{k}\right) = e^{\frac{-1}{k^2}} $$
Added in response to OP's question
Here are calculations for $N=4$ $$ \frac{ e^{-(1/4)^2}+ e^{-(2/4)^2}+ e^{-(3/4)^2}+ e^{-(4/4)^2}}{4} \\ \frac{ 0.9394+ 0.7788+ 0.5698+ 0.3679}{4} = 0.664$$
For $N=6$
$$\frac{ e^{-(1/6)^2}+ e^{-(2/6)^2}+ e^{-(3/6)^2}+ e^{-(4/6)^2}+ e^{-(5/6)^2}+ e^ {-(6/6)^2}}{6}\\ \frac{0.972604+ 0.894839+ 0.778801+ 0.64118+ 0.499352+ 0.367879}{6} = 0.692443 $$
For $N=8$: $$ \frac{e^{-(1/8)^2}+ e^{-(2/8)^2}+ e^{-(3/8)^2}+ e^{-(4/8)^2}+ e^{-(5/8)^2}+ e^ {-(6/8)^2}+ e^{-(7/8)^2}+ e^{-(8/8)^2}}{8} \\ =\frac{0.9845+ 0.9394+ 0.8688+ 0.7788+ 0.6766+ 0.5698+ 0.465+ 0.3679}{8} = 0.7064 $$
If you look carefully, half the numbers for $N=8$ are already calculated for $N=4$. So if you double $N$, you can save half the calculations.
If you know Richardson Extrapolation, you can estimate the limit $N\rightarrow \infty$ easily.
Related videos on Youtube
Ali Imtiaz
Updated on August 01, 2022Comments
-
Ali Imtiaz over 1 year
I had a question about Riemann Sums for exponential functions. Function in question is:
$e^{-x^2}$ [More commonly known as the Gaussian Integral.]
The integral from from 0 to 1 (definite integral with the upper limit 1 and the lower limit 0)
Using Riemann Sums, I managed to solve for a specific amount of rectangles. (e.g 5,7,9 etc). However, I wanted to solve for "n" rectangles.
How exactly would I go about doing this? I looked at a couple videos and none of them talk about exponential functions; only polynomials. I know I have to express it as a limit as n goes to infinity but I'm having trouble with it.
I know that $\Delta x$ would be $1/n$. However, I'm having trouble with the rest.
Any help would be appreciated.
-
Ali Imtiaz almost 10 yearsSee thing is, it wouldn't work for me. I need to express it as a limit so something along the lines of: sigma: (f(xi*)$\Delta x$) ($1/n$)
-
Betty Mock almost 10 years@AliImtiaz user44197 really showed you what to do, but perhaps you misunderstood his answer. He showed you the sums you need and he showed you what terms are under the $\sum$ sign. When you write $f(x_i)\Delta x(1/n)$ you are actually using $\Delta x$ twice, which is not what you want. In this case $\Delta x$ and 1/n are the same thing.
-
user44197 almost 10 years@Betty Mock Thanks Betty.
-
Ali Imtiaz almost 10 yearsI'm still having trouble understanding how exactly to do this.
-
user44197 almost 10 yearsWhat programming language are you using?
-
Ali Imtiaz almost 10 yearsNot using a programming language. Doing this by hand. It's for a homework assignment.
-
Ali Imtiaz almost 10 yearsThanks for the edit. The only problem is that I want to do it for "n" intervals and take the limit. Or is it possible to use: n(n+1)(2n+1)/6 As the above formula allows me to solve for any "n" value.
-
user44197 almost 10 yearsIf you are doing by hand, then you can't take the limit. Even $n=10$ gets to be tedious. You can't get an expression for the answer as the integral is not in a closed form. Let me add an edit to my answer as it is too painful to type here
-
Ali Imtiaz almost 10 yearsNever even heard of Richardson Extrapolation. Guess I'll leave it at this. Thanks for all your help!