Re: Is lazy evaluation of infinite series possible?
Posted by
Evan Donahue on
May 29, 2016; 3:28pm
URL: https://forum.world.st/Is-lazy-evaluation-of-infinite-series-possible-tp4897956p4898015.html
Hello,
I know infinite series are mentioned in the numerical methods book, although I haven't worked with those classes specifically.
http://files.pharo.org/books/numerical-methods/2016-04-NumericalMethods.pdfYou could also use a LazyList, depending on what you were doing, from
http://smalltalkhub.com/#!/~EvanDonahue/Lazy/x := 3.
Float e raisedTo: x. " = 20.085536923187664"
eX := LazyList wholes collect: [ :n | (x raisedTo: n) / n factorial ].
(eX take: 20) sum asFloat. " = 20.085536921517672"
2 * (Float e raisedTo: x). " = 40.17107384637533"
twoEX := eX with: eX collect: [ :a :b | a + b ].
(twoEX take: 20) sum asFloat. " = 40.171073843035344"
Will either of those work?
Evan