Re: Simple task with Mathematica

*To*: mathgroup at smc.vnet.net*Subject*: [mg63044] Re: Simple task with Mathematica*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>*Date*: Sun, 11 Dec 2005 22:25:18 -0500 (EST)*Organization*: The Open University, Milton Keynes, UK*References*: <dngvba$nd1$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Lea Rebanks wrote: > Dear Sir / Madame, > > I am currently learning how to use Mathematica at college with a view to > purchasing the program. > > Having spent a week studying the documentation / Book etc of version 4 I > am struggling to do even the most simple tasks. I have looked at other > Math programs, but I am really impressed with the numerical precision & > scope of Mathematica. Below is an example of a really easy task which I > can do in a second in Excel, however I am stuck with Mathematica 4. > Please show me the correct code to do in Mathematica. Many thanks for > your attention. > > Question:- > > Given the two columns below; I am trying to take the first column (A) > created as a list & iterate it by starting with 5 to finish with the > second column using the function A(1) = (6.5*2)-5 (starting value from > the second column) = 8. > > Then, for A(2) = (9.5*2)-8 =11 etc, etc giving the second column. > Function A(x) = x*2. > > (A)rea > > 5 > > > 6.5 > > 8 > > > 9.5 > > 11 > > > 8.5 > > 6 > > > 4.5 > > 3 > > > 9 > > 15 > > > 12.5 > > 10 > > > 12.5 > > 15 > > > 17.5 > > 20 > > > 18.5 > > 17 > > > 11 > > 5 > > > > I have tried indexing with x = Range[11] & using A[[x]]-B[[x-1]]. Sorry, > but I am really confused. > > > > Many thanks for any help you can offer. > > > > Best regards, > > > > Lea Rebanks. > Hi Lea, Assuming I have understood correctly what you did with Excel, the following lines are one of the possible approaches answering your question: In[1]:= A={6.5,9.5,8.5,4.5,9.0,12.5,12.5,17.5,18.5,11.0}; In[2]:= B=FoldList[(#2*2-#1)&, 5., A] Out[2]= {5.,8.,11.,6.,3.,15.,10.,15.,20.,17.,5.} Best regards, /J.M.