Iteration

For other uses, see Iteration (disambiguation).

Iteration is the act of repeating a process, either to generate an unbounded sequence of outcomes, or with the aim of approaching a desired goal, target or result. Each repetition of the process is also called an "iteration", and the results of one iteration are used as the starting point for the next iteration.

In the context of mathematics or computer science, iteration (along with the related technique of recursion) is a standard building block of algorithms.

Relationship with recursion

A pentagon iteration. Connecting alternate corners of a regular pentagon produces a pentagram which encloses a smaller inverted pentagon. Iterating the process produces a sequence of nested pentagons and pentagrams and also demonstrates recursion.[1]

The pentagon in the neighboring image is a good example of how iteration relates to recursion. Although iteration is used, for example, to parse a linked list, recursion becomes more natural when we step up to binary trees. The pentagon demonstrates both.[2]

Mathematics

Iteration in mathematics may refer to the process of iterating a function i.e. applying a function repeatedly, using the output from one iteration as the input to the next. Iteration of apparently simple functions can produce complex behaviours and difficult problems - for examples, see the Collatz conjecture and juggler sequences.

Another use of iteration in mathematics is in iterative methods which are used to produce approximate numerical solutions to certain mathematical problems. Newton's method is an example of an iterative method. Manual calculation of a number's square root is a common use and a well-known example.

Computing

Iteration in computing is the repetition of a block of statements within a computer program. It can be used both as a general term, synonymous with repetition, and to describe a specific form of repetition with a mutable state. Confusingly, it may also refer to any repetition stated using an explicit repetition structure, regardless of mutability.

When used in the first sense, recursion is an example of iteration, but typically using a recursive notation, which is typically not the case for iteration.

However, when used in the second (more restricted) sense, iteration describes the style of programming used in imperative programming languages. This contrasts with recursion, which has a more declarative approach.

Used in the third sense, repetitions using while or for loops as well as those using map or fold functions may be considered iterations.

Here is an example of iteration relying on destructive assignment, in imperative pseudocode:

a = 0
for i from 1 to 3        // loop three times
{
  a = a + i              // add the current value of i to a
}
print a                  // the number 6 is printed (0 + 1; 1 + 2; 3 + 3)

In this program fragment, the value of the variable i changes over time, taking the values 1, 2 and 3. This changing valueor mutable stateis characteristic of iteration.

Iteration can be approximated using recursive techniques in functional programming languages. The following example is in Scheme. Note that the following is recursive (a special case of iteration) because the definition of "how to iterate", the iter function, calls itself in order to solve the problem instance. Specifically it uses tail recursion so it does not use large amounts of stack space.

(let iterate ((i 1) (a 0))
  (if (<= i 3)
    (iterate (+ i 1) (+ a i))
    (display a)))

An iterator is an object that provides iteration as a generic service, allowing iteration to be done in the same way for a range of different data structures. Conversely, an iteratee is an abstraction which accepts or rejects data during an iteration process (controlled externally by an enumerator - so unlike with code that uses iterators, the iteratee code is not "in charge" of the iteration process).

Iteration is also performed using a worksheet, or by using solver or goal seek functions available in Excel. Many implicit equations like the Colebrook equation can be solved in the convenience of a worksheet by designing suitable calculation algorithms.[3]

Many of the engineering problems like solving Colebrook equations reaches 8-digit accuracy in as small as 12 iterations and a maximum of 100 iterations is sufficient to reach a 15-digit accurate result.[4]

Project management

Main article: Project management
Iterations in agile project management

Iterations in a project context may refer to the technique of developing and delivering incremental components of business functionality, product development or process design. This is most often associated with agile software development, but could potentially be any material. A single iteration results in one or more bite-sized but complete packages of project work that can perform some tangible business function. Multiple iterations recurse to create a fully integrated product. This is often contrasted with the waterfall model approach.

Education

Main article: Educational theory

In some schools of pedagogy, iterations are used to describe the process of teaching or guiding students to repeat experiments, assessments, or projects, until more accurate results are found, or the student has mastered the technical skill. This idea is found in the old adage, "Practice makes perfect." In particular, "iterative" is defined as the "process of learning and development that involves cyclical inquiry, enabling multiple opportunities for people to revisit ideas and critically reflect on their implication."[5]

See also

References

  1. B. Green (2012). Programming Problems. San Bernardino: CreateSpace. p. 25. ISBN 978-1475071962.
  2. Eric Roberts (2006). Thinking Recursively with Java. New York: Wiley. p. 171. ISBN 978-0471701460.
  3. "Solve Implicit Equations Inside Your Worksheet".
  4. "Colebrook Equation".
  5. Helen Timperley, Aaron Wilson, Heather Barrar, and Irene Fung. "Teacher Professional Learning and Development: Best Evidence Synthesis Iteration [BES]" (PDF). OECD. p. 238. Retrieved April 4, 2013.
This article is issued from Wikipedia - version of the Tuesday, April 19, 2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.