[Date Index]
[Thread Index]
[Author Index]
Re: How to Multiply a Sequence of #s that depends on the previous #
*To*: mathgroup at smc.vnet.net
*Subject*: [mg125098] Re: How to Multiply a Sequence of #s that depends on the previous #
*From*: Bill Rowe <readnews at sbcglobal.net>
*Date*: Tue, 21 Feb 2012 06:14:48 -0500 (EST)
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
On 2/20/12 at 2:46 AM, clutchderivative at gmail.com (Clutch) wrote:
>I have a list of #s : 1.10, 1.15, 1.20, 1.35.
>I start off with 50 and the first # is 50 * 1.10.
>The second # is the first # * 1.15.
>The third # is the second # * 1.20.
>The fourth # is the third # * 1.35.
>I want to maintain a list of these #s. How can this be done
>efficiently in Mathematica without running for loops?
If I understand correctly, you can do this by:
In[3]:= lst = FoldList[Times, 50, {1.1, 1.15, 1.2, 1.35}]
Out[3]= {50,55.,63.25,75.9,102.465}
and to show each subsequent value in lst has the correct ratio
In[4]:= 1/Divide @@@ Partition[lst, 2, 1]
Out[4]= {1.1,1.15,1.2,1.35}
Prev by Date:
**Re: How to Multiply a Sequence of #s that depends on the previous #**
Next by Date:
**Re: How to Multiply a Sequence of #s that depends on the previous #**
Previous by thread:
**Re: How to Multiply a Sequence of #s that depends on the previous #**
Next by thread:
**Re: How to Multiply a Sequence of #s that depends on the previous #**
| |