Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Array from for-loop iterations
Replies: 5   Last Post: Mar 3, 2011 6:04 AM

 Messages: [ Previous | Next ]
 Bob Hanlon Posts: 2,604 Registered: 1/29/05
Re: Array from for-loop iterations
Posted: Mar 3, 2011 6:04 AM

vec = Array[a, {8, 3}];

f0 = 0.5;

sol1 = (#[[3]] - f0)^2 + (#[[1]] - f0) (#[[2]] - #[[1]]) -
(#[[2]] - f0) (#[[3]] - f0) & /@ vec

sol1 == Table[(vec[[k, 3]] - f0)^2 + (vec[[k, 1]] - f0) (vec[[k, 2]] -
vec[[k, 1]]) - (vec[[k, 2]] - f0) (vec[[k, 3]] - f0), {k,
Length[vec]}]

True

Bob Hanlon

---- Lengyel Tamas <lt648@hszk.bme.hu> wrote:

==========================
Dear Mathworld Community,

I am tackling a simple problem,

I have written a simple for-loop using elements from an array of
3-dimensional vectors:

f0=0.5;
For[k = 1, k < 9, k++,

(vec[[k, 3]] - f0)^2 + (vec[[k, 1]] - f0) (vec[[k, 2]] - vec[[k, 1]]) -
vec[[k, 2]] - f0) (vec[[k, 3]] - f0)
]

I don't know how to make an array out of the computed results.

Thank you.

Tam=C3=A1s

Date Subject Author
3/2/11 Lengyel Tamas
3/3/11 Bill Rowe
3/3/11 astanoff
3/3/11 Peter Pein
3/3/11 Bob Hanlon
3/3/11 DrMajorBob