Small Steps Part 1

ITERATIVE CALCULATIONS
Harold Brochmann


Comment

In the discussions that follow, explanations involve the use of a spreadsheet application such as Excel. Readers who do not have access to, and facility with, such software will be at a disadvantage.

The topics covered involve displacement, force and acceleration vectors, ie: dynamics. Some prior understanding of this topic as well as a reasonable comfort level with trigonometry is required. The difficulty level is not above that of Senior High School.

Iterative and Newtonian Functions Compared

Suppose you borrow some money; for the purposes of this example, the sum is $100. The lender charges 12% interest, compounded monthly. You agree to pay back the loan together with accumulated interest, in exactly one year.

To find how much you have to pay back, you apply this formula:

A = P*(1 + r)^n

where

P [principal] = 100

r [rate of interest per compounding period] = 0.12/12

n [number of compounding periods] = 12

so

A = $100*(1 + (0.12/12))^12

= $112.68

The answer is found 'in one step'. This is what I call a 'newtonian function'.

Another approach is to divide the year into twelve 'time slices' and consider what happens in each.

Interest is being charged at the rate of 1% per month, so in the first one-month time slice, the interest due is 0.01 * $100.00 = $1.00. This means that during the second month $101.00 is owed and the interest on this is 0.01 * $101.00 = $1.01, so that during the third time slice the amount owed is $102.01. And so on.

This is conveniently set up on a spreadsheet template. The result looks something like this:

... except that here we have interated 1200 times instead of 12, giving us the amount owed after 100 years instead of 1 year. This was done simply to reinforce that with computers, once you have set a calculation sequence up, repeating it a very large number of times is no trouble at all.

The bolded cells contain formulae rather than numbers.

Calculations involving a series of identical steps where the input of one step is the output of the previous step are called 'iterative functions'.

Historically, much of applied mathematics research has been devoted to finding useful newtonian functions. Iterative functions are not as elegant, are easier to understand and much simpler to derive and apply - hence they are a good deal more practical. On the other hand, they require the use of computers.

Iterative calculations can be used to solve problems traditionally dealt with by 'the calculus'. This leads one to ask:"If Newton had had a computer, would he have invented calculus?".

The answer to this question is: "Probably not, as there would have been no need."

The discussion continues with an elementary physics problem.


Iterative Calculations Related to a Freely Falling Object

Comment

A falling object, in the absence of air resistance please note, increases its downwards speed by 9.8 m/sec for every second it falls. It is said to accelerate at 9.8 m/sec^2. The value 9.8 m/sec^2 is usually referred to by the shorthand "g".

increase in speed = acceleration * time

or

v(f) = v(i) + g * time

v(f) = final velocity;

v(i) = initial velocity

So, if an object (say, an iron ball) is dropped, then at time 0 it will have an initial velocity of 0 m/sec, and 10 seconds later it will have:

v(f) = 0 m/s + 9.8 m/s^2 * 10 s

= 98 m/s

The (downward) distance fallen during any time period is the average velocity during that time period multiplied by the duration of the time period. Average velocity is half the sum of initial and final velocity. The distance fallen is the product of average velocity and the duration of the time period:

s = (v(i) + v(f))/2 * t

In this case the iron ball will have fallen

s = (0 m/s + 98 m/s)/2 * 10 s

= 490 m

During the next 10 second period, the initial velocity is 98 m/s, the final velocity is:

v(f) = v(i) + g * time

= 98 m/s + 9.8 m/s^2 * 10s

= 196 m/s

The distance falled during the second time period:

s = (v(i) + v(f))/2 * t

= (98 m/s + 196 m/s)/2 * 10 s

= 1470 m

This is pretty standard stuff in any High School Physics course. We cover it here by way of review in preparation for our planned discussion of using iterative functions to calculate things which are difficult to do by other means.

With this in mind, let's set up a spreadsheet template that does the calculations we have just discussed:

Here we see what happens during successive 0.1 s time slices. At the end of the 100th 0.1 s time slice, 10 seconds have passed and the total distance fallen is 490 m. The bolded cells contain formulae. The setting up of the formulae in the template are left to the reader. Cells A1, B6 and E6 contain numbers rather than formulae.

Note that in this calculation the size of the time slice does not affect the outcome. 10 secs, 1 sec., 0.01 sec... the result is always the same. We will come back this later... but for now we note that the acceleration is constant. In some problems the acceleration is not constant; and in these calculations the magnitude of the time slice does matter.


Review of Directions

The most convenient way to refer to directions is using the 'bearing' system. 'North' on a map, the Y axis on the coordinate plane and bearing zero, are all 'up' on the paper. Bearings are measured clockwise in degrees from this reference direction. Another unit of angle measure is the radian. I am sometimes tempted to use radians because a lot of software uses radians in trigonometric calculations, including Excel. However, most readers of this material are likely to be more comfortable with degrees.

I've used metric measure for many years; but when I'm in the boat I'm much more relaxed thinking of the depth of the water in feet and the distances travelled in nautical miles! On the other hand, while driving, I'm just about equally adjusted to kph and mph! Knots just don't make sense on the highway. On the other hand, when I'm doing carpentry, it's got to be inches! Familiarity is everything.


In the discussions that follow we will be using spreadsheet templates for calculations. By way of practise in setting these up, try to replicate this template:


Review of Angle Units

As mentioned, Excel, and most spreadsheet programs, perform their calculations using 'radians'. 1 degree = /180 radians. This means that when using trigonometric functions in spreadsheets, angles in degrees must first be converted into radians. Here is a spreadsheet template showing the relationship between radians and degrees: Try to set up the template. The formul in cell B4 is: = A4 * PI() / 180. The formula in B11 is : = A11 / PI() * 180


Review of Polar Coordinates

The most familiar coordinate system is the Cartesian Coordinate System, also known as the Coordinate Plane:
The point at which the axes intersect is called the origin. Points are specified by a pair of numbers called the coordinates of the point. Nothing new here.

There is another way of describing relative positions on a plane. This is the Polar Coordinate System.
Using the Polar Coordinate System the locations of points are specified by their bearing and distance from the origin. Note that neither the X axis nor the negative portion of the Y axis now have a function. In fact, the 'Y axis' doesn't even have a name - it's just the reference direction.


Review of Vectors

A vector is 'an arrow' which represents direction and magnitude of, for example, displacement, force, velocity, acceleration.

Note that the lines from the origin to points in the last diagram are not vectors. In fact they are never shown. They were included here for illustrative purposes only.

Consider two displacements; V1 = 90 deg,3m [a movement 3 metres due east, or bearing 90] and V2 = 2 m, 200 deg.2m.

We place the starting point, P0(X0,Y0) at the origin.

The first displacement places us at P1(90,3). The second displacement places us at P2(b2,m2) where b2 is the bearing from the prigin to P2, and m2 is the magnitude of the resultant displacement vector Vr which is seen to be the sum of V1 & V2.

This is not a course in trigonometry so I will not develop the method of doing this calculation. Here are the equations we need:

br = -1*atan(((m1*cos(b1)) + m2*cos(b2))/((m1*sin(b1))+ m2*sin(b2)))+90

mr = sqrt(((m1*sin(b1))+ m2*sin(b2))^2 + ((m1*cos(b1)) + m2*cos(b2))^2)

The values from the example are:

b1 = 90

m1 = 3

b2 = 200

m2 = 2

Substituting into the equations yields:

br = 129.059

mr = 2.983

Here is a spreadsheet template that allows convenient vector additions.


Vectors representing velocities may be added in a similar manner. You can use a vector diagram to determine the answer to questions such as: If the wind is blowing at 5 km/hr from the east and you walk at 3 pm/hr towards the north west. From what direction is the apparent wind, and how strong is it? This sort of thing is of interest to people who race sailboats like myself.

According to Newton's First Law of motion, an object subjected to a force undergoes an acceleration. Two or more forces may be acting on an object at the same time. Vectors representing constant accelerations may be added in a similar manner.

Three notes of clarification at this point.:

The difference between the terms speed and velocity is that velocity includes a specification of direction as well as magnitude, while speed does not. In other words, 10 m/s refers to speed, while 10 m/s at bearing 215 degrees refers to velocity. This means that speed is not a vector quantity, while velocity is.

Also, acceleration refers to change in velocity. The change may be in the magnitude or the direction component. Consider now the moon in orbit around the Earth. Its speed of rotation remains constant (well, very nearly so); but in as much as the direction in which it travels is continuously changing - it follows a circular path, not a straight line), its velocity is also continuously changing, and thus it is accelerating.

Newton's First Law states that force = mass * acceleration. Mass may be measured in kilograms, acceleration may be measured in m/sec^2. The unit of force is therefore kg*m/sec^2


Non Constant Acceleration

Adding vectors allow us to investigate all sorts of theoretical phenomena. I say 'theoretical' because in the real world most accelerations are not constant because the forces to which moving objects are subjected change. A freely falling object, for example is in reality also subjected to air resistance... and it varies with speed. As something falls, the resistance provided by the air increases disporoportionately; not in a linear manner. For some time it was assumed that air resistance was proportional to the square of the speed. But that turns out to not be true either. This particular topic is discussed in my article on ballistics elsewhere on the web page.

The point is that when it comes to non constant acceleration, vector addition and newtonian functions don't get us anywhere. We have to resort to the technique illustrated at the beginnng of this dissertation - of breaking time into very small slices and doing iterative calculations.

Consider for example, the problem of making a clock based on a pendulum. Our High School Physics teacher told us that the period of a pendulum can be found by

T = 2 * PI * sqrt(l/g)

For example, a pendulum 1 m long will have a period of

T = 2 * 3.14 * sqrt(1 m / 9.8 m /sec^2)

= 2.007 s

This turns out to be true only if the swing of the pendulum is very slight. If the pendulum swings at all wide the formula simply doesn't work any more. A real problem for early clock makers. This is a topic touched upon in my article on phase state diagrams found elsewhere on this web page. In the next section we do the detailed calculations on this problem.

Another example: The gravitational force exerted by for example the Sun, on a orbiting object, for example a comet, varies with the distance between them. This means that the acceleration of the comet changes and calculating its orbit used to be horrendously complicated. Add a third gravitational object like the Earth, and you have the famous 'three body problem' which is in principle not solvable using netwtonian functions. You have to use iterative techniques. These were used in the computer program that generated the first diagram you see in the article called Chaos vs Determinism Part 2 elsewhere on the web page. This calculation is the subject of the fourth article in this series.

This material is in the development phase. Your e-mail with comments and suggestions solicited.

Small steps part 2