View Single Post
  #8  
Old April 26th, 2010, 04:39 AM posted to microsoft.public.excel.worksheet.functions
minyeh
external usenet poster
 
Posts: 29
Default How to Sum infinite formula

On Apr 26, 4:43*am, Dana DeLouis wrote:
Hi. *Here is a slight addition that you can play with if you wish.
I just modified this portion so we can watch the convergence.
I also eliminated multiplying the answer by 100.
Just format the output as percentage to 3 decimal places does the same
thing!

* * * * *For J = 2 To 20
* * * * * * *.Add "k", Y / Fx.Fact(J) * *' T/j!
* * * * * * *.Add "M", [MMult(M, Orig)] *'Matrix to the next power

* * * * * * *.Add "Old", [Ans]
* * * * * * *.Add "Ans", [Ans + k*M] * * 'Sum
* * * * * * *Debug.Print J; Fx.SumXMY2([Old], [Ans])
* * * * *Next J
* * * * *[A12].Resize(9, 9) = [Ans]
* * *End With
End Sub

The output is:
* 2 *0.03359136055325
* 3 *9.2432006386492E-04
* 4 *1.54269946074966E-05
* 5 *1.72307843099531E-07
* 6 *1.35605071782519E-09
* 7 *7.91983983820038E-12
* 8 *3.54955567034313E-14
* 9 *1.25992350330859E-16
* 10 *3.62323283207642E-19
* 11 *8.61641664106313E-22
* 12 *1.72167126878345E-24
* 13 *2.93590834028579E-27
* 14 *4.50356058499773E-30
* 15 *1.36904585529777E-32
* 16 *4.48415508583941E-44
* 17 *0
* 18 *0
* 19 *0
* 20 *0

We can see that around 8-9 loops is all that's needed.
One can modify the code to exit once the difference gets below a certain
level.

= = = = =
HTH
Dana DeLouis

snip


checking the convergence is a good idea, would be very helpful in
determining how many loops required as a cut-off point. : ) Thanks a
lot really, you have been very helpful Dana.


Regards,
Min Yeh