       • To: mathgroup at smc.vnet.net
• Subject: [mg63045] Re: [mg63040] Simple task with Mathematica
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Sun, 11 Dec 2005 22:25:19 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```a={5, 6.5, 9.5, 8.5, 4.5, 9, 12.5, 12.5, 17.5, 18.5, 11};

b=Rest[FoldList[2*#2-#1&, First[a], Rest[a]]]

{8.,11.,6.,3.,15.,10.,15.,20.,17.,5.}

or alternatively

For[k=2;b=a, k<=Length[a], k++, b[[k]]=2*a[[k]]-b[[k-1]]];

b=Rest[b]

{8.,11.,6.,3.,15.,10.,15.,20.,17.,5.}

Bob Hanlon

>
> From: "Lea Rebanks" <lrebanks at onetelhk.net>
To: mathgroup at smc.vnet.net
> Date: 2005/12/11 Sun AM 04:57:35 EST
> Subject: [mg63045] [mg63040] Simple task with Mathematica
>
>
> I am currently learning how to use Mathematica at college with a view to
>
> 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
>
> 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 & using A[[x]]-B[[x-1]]. Sorry,
> but I am really confused.
>
>
>
>
>
>
> Best regards,
>
>
>
> Lea Rebanks.
>
>

```

• Prev by Date: Re: A list of numbers without "73"
• Next by Date: Re: Simple task with Mathematica