Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

Re: How to do a simple loop?

  • To: mathgroup at
  • Subject: [mg30433] Re: How to do a simple loop?
  • From: "Oliver Friedrich" <oliver.friedrich at>
  • Date: Sat, 18 Aug 2001 04:04:57 -0400 (EDT)
  • References: <9ligqt$is2$>
  • Sender: owner-wri-mathgroup at

Hi Vadim,

1. To print the function i times


It creates a list with i elements. Each element represents your desired

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> schrieb im Newsbeitrag
news:9ligqt$is2$1 at
> 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,
> Vadim.

  • Prev by Date: Re: Rotation3D, MatrixRotation3D ?
  • Next by Date: Re: byte[ ] of J/Link
  • Previous by thread: How to do a simple loop?
  • Next by thread: Re: How to do a simple loop?