To add payments at interest rates, you should first discount or accumulate the payments to a single point in time, then add them up, then reverse the first step. You need to take care whether payments are in advance or arrears.
e.g. the following discounts payments to time 0: p=. 100 200 300 i=. 0.05 0.06 0.07 acc=. */\1+i acc * +/\p % 1,}:acc 105 323.3 666.931 See also the finance/interest addon. On 28 November 2015 at 12:27, John Baker <[email protected]> wrote: > A nasty combination of too much recent programming in loopy languages > combined with advancing age has dulled my memory of how to properly grow a > rate adjusted series without looping. The following solves my immediate > problem but my sense of J aesthetics is appalled. > > Would anyone care to provide a more J'ey solution. > > AccumulateSeries2=:4 : 0 > > > NB.*AccumulateSeries2 v-- accumulate rate adjusted current and > > NB. future series credits and charges. > > NB. > > NB. dyad: nl =. ia AccumulateSeries2 ntSeriesGrowth > > NB. > > NB. sr=. ((5#100),0 0 _80 0 0 200 200) ,: (6#1),6$1.001667 0.98 1 > > NB. (3 AccumulateSeries2 sr) ,: 0{sr > > > 'sv gr'=. y > > > NB. forward last actuals and accumulate rate adjusted > > pv=. x {. sv > > cv=. (_1 {. pv) , x }. sv > > cg=. (_1 {. x {. gr) , x }. gr > > > for_j. i.<:#cv do. > > cv=. (((>:j){cv) + (j{cg) * j{cv) (>:j)} cv > > end. > > > pv , }. cv > > ) > > > -- > John D. Baker > [email protected] > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
