Solution to Infinite series for E^(n^2x)

2 replies · 2K views · last reply
IanM
Messages
2
Reaction score
0
This is my first time posting so forgive me if I have it in the wrong place,

i'm trying to find a solution to the following that I can stick into either excel or a VBA script. It has been 25 years since I looked at any serious maths and I'm stumped. I can find and digest e^-(n^2y) but can't work out the n^-2 addition. Happy to be walked though the steps if it helps me get a better understanding, for those interested it is part of a solution to determine the ability for gas to flow though a porous medium

View attachment 6510

Cheers

Ian
 
Attachments
  • Equation: F_r = (6/π) times the sum from n = 1 to infinity of exp(-(π² n² K t)/r_s) times 1/n², written as plain text in the image.
    Capture.JPG
    3.4 KB · Views: 158
IanM said:
This is my first time posting so forgive me if I have it in the wrong place,

i'm trying to find a solution to the following that I can stick into either excel or a VBA script. It has been 25 years since I looked at any serious maths and I'm stumped. I can find and digest e^-(n^2y) but can't work out the n^-2 addition. Happy to be walked though the steps if it helps me get a better understanding, for those interested it is part of a solution to determine the ability for gas to flow though a porous medium
Cheers

Ian

Hi IanM,

The usual way to make an approximation is to keep summing subsequent terms until the next term is below a certain threshold.
Something like:
Code:
n = 0
sum = 0
do
  n = n + 1
  term = (6 / pi) * exp(-(pi^2) * (n^2) * Kt / rs) / n^2
  sum = sum + term
while term > 0.0001
That will give us a result that is accurate up to the first 4 digits after the dot.
We'd have to look up how to do that in VBA exactly.

Alternatively, we can create a fixed column of numbers of, say, 1..10 in cells A1:A10.
And calculate the result up to $n=10$ as:
[M]=SUM((6/PI()) * EXP(-3*$A$1:$A10^2)/$A$1:$A10^2)[/M]
Use Ctrl+Shift+Enter when entering the formula, making it an array-formula.
Afterwards, it will show up as:
[M]{=SUM((6/PI()) * EXP(-3*$A$1:$A10^2)/$A$1:$A10^2)}[/M]

Or even fancier in a single cell:
[M]{=SUM((6/PI()) * EXP(-3*{1,2,3,4,5}^2)/{1,2,3,4,5}^2)}[/M]
(Don't forget Ctrl+Shift+Enter.)

We'll have to experiment a bit to see how many iterations are enough.
We could check whether
[M]{=SUM((6/PI()) * EXP(-3*{1,2,3,4,5,6}^2)/{1,2,3,4,5,6}^2) - SUM((6/PI()) * EXP(-3*{1,2,3,4,5}^2)/{1,2,3,4,5}^2)}[/M]
can be considered small enough. This is the indicator for the error in the result.
 
Fantastic thanks for the Help, even better it makes sense!