I am trying to create an array, or rather just a table, from the results of the root finding procedure, calculated with a set of input parameters. This is what I wrote:
pvec = {0.03, 0.06, 0.09, 0.12, 0.15}
Xpvec = Table[0, 5]
While[n < 6,
FindRoot[1 - 3/(8 Xp^3) (2 Xp^2 - 1 + (1 + 2 Xp) Exp[-2 Xp]) ==
pvec[[n]], {Xp, 0.01, 0.5}];
xtemp = Xp /. %; Xpvec[[n]] = xtemp; i++]
But when I run this small piece, I got a number of error messages. On the other hand, if I specify any given value of n betweeen 1 and 5, and run the kernel of the While statement, it gives the correct result, so I can build my Xpved table manually. What is wrong with the While loop?