MathGroup Archive 2012

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

Search the Archive

Re: Why the loop gain no result?


On Apr 14, 12:11 am, Huafeng Cao <geotom.... at gmail.com> wrote:
> I use the 'For' loop to solving an equation, such as :
>     For[i = 1, i < 5, i++, a = i; Solve[a*x^2 - 2 x + 1 == 0, x]].
> The 'a' in the body must be updated in every loop with the 'i'.
> But i can't gain the result, Somewhere is disorder? I am confused.

No, you don't need the 'a'. But if you want to see the results
then you need to Print them:
  For[i = 1, i < 5, i++, Print@Solve[i*x^2 - 2 x + 1 == 0, x]]
or put them in a Table:
  Table[Solve[i*x^2 - 2 x + 1 == 0, x], {i,4}]



  • Prev by Date: How to call Mathematica Boolean functions from non-Mathematica apps
  • Next by Date: Re: Why the loop gain no result?
  • Previous by thread: Re: Why the loop gain no result?
  • Next by thread: Re: Why the loop gain no result?