Re: Noob requests help with recursive formula
- To: mathgroup at smc.vnet.net
- Subject: [mg130150] Re: Noob requests help with recursive formula
- From: Ray Koopman <koopman at sfu.ca>
- Date: Thu, 14 Mar 2013 07:15:30 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- References: <khpco1$mdi$1@smc.vnet.net>
On Mar 13, 1:18 am, Garcia5... at yahoo.fr wrote: > I have two lists, each with 99 elements; A and B. Real numbers. > I want to form a list, C, whose elements are functions (F[]) > of A and B, and also previous elements of C itself. > > C = {F[A1/B1], F[A2/(B2-A1/C1)], F[A3/(B3-A1/C1-A2/C2)], ..., > F[A99/(B99-A1/C1 ... -A98/C98.)} ...where the integers after A,B,C are element indices. First define a helper function: cr[{c_,r_},{a_,b_}] := {#, r+a/#}& @ f[a/(b-r)] Then use FoldList. Here is an example with 3 elements: Rest@FoldList[cr,{0,0},Transpose@ {{a1,a2,a3},{b1,b2,b3}}][[All,1]] //InputForm {f[a1/b1], f[a2/(b2 - a1/f[a1/b1])], f[a3/(b3 - a1/f[a1/b1] - a2/f[a2/(b2 - a1/f[a1/b1])])]}