Iteration

Home Up Run First Loop 
This Page Format is Obsolete!  Go to new site : http://www.science-ebooks.com/javascript-js.html

This Site will go away in spring of 2016:  Please visit http://www.science-ebooks.com to see NEW SITE!

 

Run First Loop

series 2 pure

 

Iteration and Higher mathematics

 

This Page Format is Obsolete!  Go to new site : http://www.science-ebooks.com/javascript-js.html

This Site will go away in spring of 2016:  Please visit http://www.science-ebooks.com to see NEW SITE!

 

 

 

Iteration

Mathematics. A computational procedure in which a cycle of operations is repeated, often to approximate the desired result more closely.

Computer Science.

  1. The process of repeating a set of instructions mamy times or until a specific result is achieved.
  2. A cycle of a set of instructions to be repeated: After ten iterations, the program exited the loop.

Mathematics Application:

Algebra - In algebra you learned to solve equations for X. Your teacher may have told you to check your answer by substituting that number into the equation.  If your answer resulted in a equality, you can be certain that your answer was correct.  With a computer you can skip solving the equation and simply search for the solution by testing every number in a finite set of numbers.  For example, if you knew that X was an Integer between -1000 and +1000 you would have to do 2000 iteration to find all the solution.  Programmers use looping to perform repetitive operations.

Calculus - We use calculus to calculate the area under a curve of continuous function of x.  We can approximate the area under a curve with a number of rectangles with height f(x) and width of delta x).  The smaller the value of delta x the greater the number rectangles required cover the bounded area.  One iteration or loop is required to calculate area of each rectangle.  

 

JavaScript Methods of Looping - Before doing any physics or electronics calculations let us consider some methods of looping.  

Warning: Infinite Loops can hang up your computer.  Pressing Ctrl/Alt/Delete buttons simultaneously will interrupt program operation and cause Windows Task Manager Menu to be displayed.  Use  Windows Task Manager  -  End Task button to stop your program.

For Keyword

The for loop uses an index counter to keep track of the number loops, and stops looping when a certain number is reached.


<HTML>

<head>
<TITLE>Simple Script 1</TITLE>
</head>
<Body>
<SCRIPT LANGUAGE = JavaScript>
n = 10
for (i = 1; i < 8; i++){
n = n *n; 
alert("n = "+n)
}
alert("The End")
</SCRIPT>
</Body>
</HTML>

Notes:
i = 1 is start count.
 i < 8 defines upper limit
i++ means i = i + 1 or simply increment i.

Statements in parenthesis ( ) control loop.
Statements in wiggly parenthesis {} are operations to be performed in each loop. 

 

 

 

 

 

        
Questions or problems regarding this web site should be directed to BilPat4342@AOL.com

Copyright ©2003 Science Ebooks All rights reserved.
Last modified: Monday January 18, 2016.