MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Incrementing a "For" loop - "For loop.nb" 5893 Bytes yEnc

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39712] RE: [mg39688] Incrementing a "For" loop - "For loop.nb" 5893 Bytes yEnc
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Mon, 3 Mar 2003 04:26:10 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

>-----Original Message-----
>From: twm145 at psu.edu [mailto:twm145 at psu.edu]
To: mathgroup at smc.vnet.net
>Sent: Sunday, March 02, 2003 4:05 AM
>To: mathgroup at smc.vnet.net
>Subject: [mg39712] [mg39688] Incrementing a "For" loop - "For loop.nb" 5893 Bytes
>yEnc
>
>
>I have an 11 x 11 matrix "A", and an 11 x 1 matrix "Told"
>I would like to find the dot product of A and Told and store 
>this result as Tnew
>then, increment a variable deltat that appears in A to deltat + 30.
>
>I would then like to designate the answer Tnew as Told and perform the
>calculation again, and repeat the procedure until deltat has 
>reached 3600.
>
>I have been trying to get a For loop to accomplish this but it appears that
>the incrementing of deltat and the reassignment of Tnew to Told is not
>occuring.  
[...]

>
>Tom Morris
>

It might be useful to make up a simple example (model of your computation):

a[phi_] := {{Cos[phi], -Sin[phi]}, {Sin[phi], Cos[phi]}}

...matrix 'a', depending on a parameter

t0 = {1, 0};

...starting value

delta = Pi/180.

pts = NestList[a[10*delta].# &, t0, 25];

...we get a list of values of repeated application, the parameter is not
increased here.

d[pts_] := 
  Show[Graphics[{PointSize[.03], Hue[2/3], Point /@ pts}], AspectRatio -> 1,

    PlotRange -> {{-1, 1}, {-1, 1}}, Frame -> True]

d[pts]


You see the points equidistant on the circle.
If you only want the last one, use Nest instead of NestList.



Now we also change the parameter:

pts2 = FoldList[a[#2].#1 &, t0, delta*Range[25]];

d[pts2]


You see the points "accelerating" from linear increase of the parameter
If you only want the last one, use Fold instead of FoldList.


Try to reformulate your problem in these or similar terms!

--
Hartmut Wolf



  • Prev by Date: Re: Caching of values and delayed sets
  • Next by Date: RE: Testing for invertible matrix
  • Previous by thread: Incrementing a "For" loop - "For loop.nb" 5893 Bytes yEnc
  • Next by thread: Re: Incrementing a "For" loop - "For loop.nb" 5893 Bytes yEnc