Re: Simple task with Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg63050] Re: Simple task with Mathematica
- From: Peter Pein <petsie at dordos.net>
- Date: Sun, 11 Dec 2005 22:25:24 -0500 (EST)
- References: <dngvba$nd1$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Lea Rebanks schrieb: > 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, if I understand you correctly, you want: a={6.5,9.5,8.5,4.5,9,12.5,12.5,17.5,18.5,11}; FoldList[2*#2-#1&,5,a] --> {5,8.,11.,6.,3.,15.,10.,15.,20.,17.,5.} Peter