In this chapter, we used a loop to perform a repetitive computation—updating a model 30 times—and to compute sequences and series. Also, we used the
plot function to visualize the results.
Here are some terms from this chapter you might want to remember.
Absolute error is the difference between an approximation and an exact answer. Relative error is the same difference expressed as a fraction or percentage of the exact answer.
A loop is part of a program that runs repeatedly. A loop variable is a variable that gets assigned a different value each time through the loop. A range is a sequence of values assigned to the loop variable, often specified with the colon operator—for example,
1:5. The body of a loop is the set of statements inside the loop that runs repeatedly. An accumulator is a variable that is used to accumulate a result a little bit at a time.
In mathematics, a sequence is a set of numbers that correspond to the positive integers. The numbers that make up the sequence are called . A series is the sum of a sequence of elements. Sometimes we compute the elements of a sequence recurrently, which means that each new element depends on previous elements. Sometimes we can compute the elements directly, without using previous elements.
Generalization is a way to make a program more versatile, for example, by replacing a specific value with a variable that can have any value. Incremental development is a way of programming by making a series of small, testable changes. Scaffolding is code you write to help you program or debug but that is not part of the finished program.
In the next chapter, we’ll use a vector to store the results from a loop.