Re: How to do a simple loop?

• To: mathgroup at smc.vnet.net
• Subject: [mg30450] Re: How to do a simple loop?
• From: vnagornyi at netscape.net (Vadim Nagornyi)
• Date: Tue, 21 Aug 2001 03:05:30 -0400 (EDT)
• References: <9ligqt\$is2\$1@smc.vnet.net> <9ll7pm\$m3p\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Thanks for the help, Oliver!
I thought it could be done easier, without numerical stuff.

"Oliver Friedrich" <oliver.friedrich at tz-mikroelektronik.de> wrote in message news:<9ll7pm\$m3p\$1 at smc.vnet.net>...
>
> 1. To print the function i times
>
> Table[x*i-i,{i,100}]//TableForm
>
> It creates a list with i elements. Each element represents your desired
> expression.
>
> 2. Plot the function
>
> Scan[ Plot[ x i-i, {i,0,#}]&, Range[100]]
>
> Range creates a table with elements 1 to 100. Scan operates the Plot
> function on each of that elements. The element is inserted at the # (a so
> called pure function). Careful with that x, you must replace it with a
> numerical value, cause Plot won't evaluate on non-numeric expressions.
>
> 3. Find the Integral
>
> Map[Integrate [x i-i, {x, 0, #}]&,Range[5]]
>
> Same as above, except that Map creates a list with the result.
>
> Have fun
>
> Oliver Friedrich
>
>
>
> "Vadim Nagornyi" <vnagornyi at netscape.net> schrieb im Newsbeitrag
> news:9ligqt\$is2\$1 at smc.vnet.net...
> > Still using 2.2 ...
> > OK, I have a function that depends on an integer, for example F=x*i-i.
> > For i ranging from 1 to 100 I need to perform the following:
> >
> > 1. Display the function equation.
> > 2. Plot the function in the range 0...i
> > 3. Find the integral of the function for the same range.
> >
> > The loop body looks simple:
> >
> > F
> > Plot[F, {x, 0, i}]
> > Integrate [F, {x, 0, i}]
> >
> > but how to iterare this?
> >
> > Thanks,